Skip to content

Commit

Permalink
If an exception has a response then respond with the response if the …
Browse files Browse the repository at this point in the history
…throw isnt already made into response, send it in the handler
  • Loading branch information
roncodes committed Jan 15, 2024
1 parent 5b63074 commit 9c07fa7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class Handler extends ExceptionHandler
*
* @var array
*/
protected $dontReport = [
];
protected $dontReport = [];

/**
* A list of the inputs that are never flashed for validation exceptions.
Expand Down Expand Up @@ -98,6 +97,11 @@ public function render($request, \Throwable $exception)
return response()->error($exception->getMessage());
}

// if exception has JSON response return it
if (isset($exception->response) && $exception->response instanceof \Illuminate\Http\Response) {
return $exception->response;
}

if (app()->environment(['development', 'local'])) {
return parent::render($request, $exception);
}
Expand Down

0 comments on commit 9c07fa7

Please sign in to comment.