X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/40ca50e44f3ca0f648d915dc73ff205309730f07..refs/pull/3032/head:/app/Exceptions/Handler.php diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index a06c0fdbc..2d40f4476 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -35,9 +35,10 @@ class Handler extends ExceptionHandler * Report or log an exception. * * @param Exception $exception - * @return void * * @throws Exception + * + * @return void */ public function report(Exception $exception) { @@ -47,8 +48,9 @@ class Handler extends ExceptionHandler /** * Render an exception into an HTTP response. * - * @param \Illuminate\Http\Request $request - * @param Exception $e + * @param \Illuminate\Http\Request $request + * @param Exception $e + * * @return \Illuminate\Http\Response */ public function render($request, Exception $e) @@ -83,7 +85,7 @@ class Handler extends ExceptionHandler $responseData = [ 'error' => [ 'message' => $e->getMessage(), - ] + ], ]; if ($e instanceof ValidationException) { @@ -92,14 +94,16 @@ class Handler extends ExceptionHandler } $responseData['error']['code'] = $code; + return new JsonResponse($responseData, $code, $headers); } /** * Convert an authentication exception into an unauthenticated response. * - * @param \Illuminate\Http\Request $request - * @param \Illuminate\Auth\AuthenticationException $exception + * @param \Illuminate\Http\Request $request + * @param \Illuminate\Auth\AuthenticationException $exception + * * @return \Illuminate\Http\Response */ protected function unauthenticated($request, AuthenticationException $exception) @@ -114,8 +118,9 @@ class Handler extends ExceptionHandler /** * Convert a validation exception into a JSON response. * - * @param \Illuminate\Http\Request $request - * @param \Illuminate\Validation\ValidationException $exception + * @param \Illuminate\Http\Request $request + * @param \Illuminate\Validation\ValidationException $exception + * * @return \Illuminate\Http\JsonResponse */ protected function invalidJson($request, ValidationException $exception)