Should close #244
What a peculiar bug. Also modifies code to try and return the correct status code, as well as return JSON based errors on any request that Laravel thinks should have a JSON based response.
This commit is contained in:
parent
8323477d0c
commit
f292080483
1 changed files with 3 additions and 4 deletions
|
@ -46,13 +46,12 @@ class Handler extends ExceptionHandler
|
||||||
*/
|
*/
|
||||||
public function render($request, Exception $exception)
|
public function render($request, Exception $exception)
|
||||||
{
|
{
|
||||||
if ($request->isXmlHttpRequest() || $request->ajax() || $request->is('remote/*')) {
|
if ($request->expectsJson()) {
|
||||||
$response = response()->json([
|
$response = response()->json([
|
||||||
'error' => ($exception instanceof DisplayException) ? $exception->getMessage() : 'An unhandled error occured while attempting to process this request.',
|
'error' => ($exception instanceof DisplayException) ? $exception->getMessage() : 'An unhandled error occured while attempting to process this request.',
|
||||||
], 500);
|
], ($this->isHttpException($exception)) ? $e->getStatusCode() : 500);
|
||||||
|
|
||||||
// parent::render() will log it, we are bypassing it in this case.
|
parent::report($exception);
|
||||||
Log::error($exception);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (isset($response)) ? $response : parent::render($request, $exception);
|
return (isset($response)) ? $response : parent::render($request, $exception);
|
||||||
|
|
Loading…
Reference in a new issue