diff --git a/src/Server.php b/src/Server.php index a7f7c56..308aef6 100644 --- a/src/Server.php +++ b/src/Server.php @@ -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(),