diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 23dbecd49..13534549f 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -48,6 +48,11 @@ class Handler extends ExceptionHandler */ public function render($request, Throwable $exception) { + if ($request->wantsJson()) + return response()->json( + ['error' => $exception->getMessage()], + method_exists($exception, 'getStatusCode') ? $exception->getStatusCode() : 500 + ); return parent::render($request, $exception); } }