From 09724050c285fe63ef87f2ec50cf2cd0f1211ff6 Mon Sep 17 00:00:00 2001 From: Konstantin Zamyakin Date: Sun, 11 Feb 2018 22:46:29 +0300 Subject: [PATCH 1/2] return 404 http status for missing links --- app/Exceptions/Handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 2afb883..e1b16ba 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -51,7 +51,7 @@ class Handler extends ExceptionHandler { return redirect()->to(env('SETTING_INDEX_REDIRECT')); } // Otherwise, show a nice error page - return view('errors.404'); + return response(view('errors.404'), 404); } if ($e instanceof HttpException) { // Handle HTTP exceptions thrown by public-facing controllers From c0ce7d4d6eeeac57c3dda926741fa006f2da7cb2 Mon Sep 17 00:00:00 2001 From: Chaoyi Zha Date: Sun, 11 Feb 2018 17:05:57 -0500 Subject: [PATCH 2/2] Use proper HTTP response code for pretty 500 page; reduce line length --- app/Exceptions/Handler.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index e1b16ba..4229462 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -60,11 +60,15 @@ class Handler extends ExceptionHandler { if ($status_code == 500) { // Render a nice error page for 500s - return view('errors.500'); + return response(view('errors.500'), 500); } else { // If not 500, render generic page - return response(view('errors.generic', ['status_code' => $status_code, 'status_message' => $status_message]), $status_code); + return response( + view('errors.generic', [ + 'status_code' => $status_code, + 'status_message' => $status_message + ]), $status_code); } } if ($e instanceof ApiException) {