Skip to content

Commit

Permalink
log exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmorbo committed Nov 14, 2023
1 parent 65364a2 commit a321b6f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,20 @@ function (ServerRequestInterface $request) use ($router) {

return $response;
})
->catch(function (NotFoundHttpException|TrassirException $e) {
->catch(function (NotFoundHttpException $e) {
return Response::json([
'status' => 'error',
'error' => $e->getMessage(),
]);
})
->catch(function (TrassirException|Exception $e) {
$this->logger->error('Caught an exception', [
'exception' => get_class($e),
'message' => $e->getMessage(),
'code' => $e->getCode(),
'trace' => $e->getTraceAsString(),
]);

return Response::json([
'status' => 'error',
'error' => $e->getMessage(),
Expand Down

0 comments on commit a321b6f

Please sign in to comment.