Mensaje de error
This commit is contained in:
@ -10,5 +10,23 @@
|
|||||||
<i class="hammer icon"></i>
|
<i class="hammer icon"></i>
|
||||||
Esta parte del sitio está en construcción.
|
Esta parte del sitio está en construcción.
|
||||||
</div>
|
</div>
|
||||||
|
@if (isset($exception))
|
||||||
|
<div class="ui warning message">
|
||||||
|
<i class="exclamation triangle icon"></i>
|
||||||
|
<div class="content">
|
||||||
|
<div class="header">Error</div>
|
||||||
|
<p>{{$message}}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if (isset($error))
|
||||||
|
<div class="ui error message">
|
||||||
|
<i class="exclamation triangle icon"></i>
|
||||||
|
<div class="content">
|
||||||
|
<div class="header">Error</div>
|
||||||
|
<p>{{$message}}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -15,17 +15,22 @@ class Errors
|
|||||||
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
|
public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||||
{
|
{
|
||||||
|
$output = [];
|
||||||
try {
|
try {
|
||||||
return $handler->handle($request);
|
return $handler->handle($request);
|
||||||
} catch (Exception $exception) {
|
} catch (Exception $exception) {
|
||||||
|
$output['message'] = $exception->getMessage();
|
||||||
|
$output['exception'] = $exception;
|
||||||
$this->logger->warning($exception);
|
$this->logger->warning($exception);
|
||||||
} catch (Error $error) {
|
} catch (Error $error) {
|
||||||
|
$output['message'] = $error->getMessage();
|
||||||
|
$output['error'] = $error;
|
||||||
$this->logger->error($error);
|
$this->logger->error($error);
|
||||||
}
|
}
|
||||||
$response = $this->responseFactory->createResponse(500, 'Internal Server Error');
|
$response = $this->responseFactory->createResponse(500, 'Internal Server Error');
|
||||||
if (str_contains($request->getUri()->getPath(), '/api')) {
|
if (str_contains($request->getUri()->getPath(), '/api')) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
return $this->view->render($response, 'construccion');
|
return $this->view->render($response, 'construccion', $output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user