Mejora en respuesta cuando no existe algun valor.

This commit is contained in:
Juan Pablo Vial
2025-05-05 16:43:24 -04:00
parent 5f63bdbf4a
commit 972e57b6f1
2 changed files with 16 additions and 5 deletions

View File

@ -8,17 +8,21 @@ use Psr\Http\Server\RequestHandlerInterface;
use Psr\Log\LoggerInterface;
use Slim\Exception\HttpNotFoundException;
use Incoviba\Common\Alias\View;
use Incoviba\Common\Implement\Exception\{EmptyRedis,EmptyResult};
use Incoviba\Exception\ServiceAction\{Create, Delete, Read, Update};
class NotFound
{
public function __construct(protected LoggerInterface $logger, protected ResponseFactoryInterface $responseFactory, protected View $view) {}
public function __construct(protected LoggerInterface $logger, protected ResponseFactoryInterface $responseFactory,
protected View $view) {}
public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
try {
return $handler->handle($request);
} catch (HttpNotFoundException $exception) {
} catch (HttpNotFoundException |
EmptyRedis | EmptyResult | Read | Create | Update | Delete $exception) {
$this->logger->notice($exception);
$response = $this->responseFactory->createResponse(404);
$response = $this->responseFactory->createResponse(404, 'Not Found');
if (str_contains($request->getUri()->getPath(), '/api')) {
return $response;
}