29 lines
728 B
PHP
29 lines
728 B
PHP
<?php
|
|
|
|
namespace App\Exceptions\WebService\Ambulatorio\ConectaSus;
|
|
|
|
use Exception;
|
|
use Illuminate\Http\Response;
|
|
|
|
class LocalAnatomicoNotFoundException extends Exception
|
|
{
|
|
private string $valor;
|
|
private ?int $indice;
|
|
public function __construct(string $valor, ?int $indice = null)
|
|
{
|
|
$this->valor = $valor;
|
|
$this->indice = $indice;
|
|
parent::__construct();
|
|
}
|
|
public function render()
|
|
{
|
|
$msg = "Local anatômico '{$this->valor}' não encontrado.";
|
|
if ($this->indice !== null) {
|
|
$msg = "Ferida [{$this->indice}]: {$msg}";
|
|
}
|
|
return response()->json([
|
|
'message' => $msg
|
|
], Response::HTTP_UNPROCESSABLE_ENTITY);
|
|
}
|
|
}
|