From 8f0ab1e719b86dba4b495e67fa77fb275bd1419a Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 24 Jan 2017 18:56:15 -0800 Subject: [PATCH] Fixed weird status code error on ajax --- app/Exceptions/Handler.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 6a931372f..dad7b5b60 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -63,9 +63,11 @@ class Handler extends ExceptionHandler if ($this->isHttpException($e)) { + $statusCode = $e->getStatusCode(); + switch ($e->getStatusCode()) { case '404': - return response()->json(Helper::formatStandardApiResponse('error', null, $statusCode . ' not found'), 404); + return response()->json(Helper::formatStandardApiResponse('error', null, $statusCode . ' endpoint not found'), 404); break; case '405': return response()->json(Helper::formatStandardApiResponse('error', null, 'Method not allowed'), 405); @@ -79,17 +81,10 @@ class Handler extends ExceptionHandler } - if ($this->isHttpException($e)) { - - $statusCode = $e->getStatusCode(); - - switch ($statusCode) { - - case '404': - return response()->view('layouts/basic', [ - 'content' => view('errors/404') - ]); - } + if ($this->isHttpException($e) && (isset($statusCode)) && ($statusCode == '404' )) { + return response()->view('layouts/basic', [ + 'content' => view('errors/404') + ]); } return parent::render($request, $e);