From 8ba38dcf7fbd96a6f13639057e045eba114e2f39 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 7 Jul 2018 16:50:10 +0200 Subject: Even better http error messages --- app/Exceptions/Handler.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'app/Exceptions') diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 217b6e1..0e458d9 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -50,8 +50,15 @@ class Handler extends ExceptionHandler { if ($exception instanceof HttpException) { $statusCode = $exception->getStatusCode(); + switch ($statusCode) { + case '404': + $codeMessage = 'Page could not be found'; + } + $errorMessage = $exception->getMessage() == '' ? ($codeMessage ? $codeMessage : 'An unknown error occurred.') : $exception->getMessage(); + + return response(View::make('errors.http', [ - 'ErrorMessage' => $exception->getMessage() == '' ? 'An unknown error occurred.' : $exception->getMessage(), + 'ErrorMessage' => $errorMessage, 'ErrorCode' => $statusCode ]), $statusCode); } -- cgit v1.2.3