Last active
December 19, 2016 19:11
-
-
Save messi89/e8fc907738cded6e8357899eea135805 to your computer and use it in GitHub Desktop.
Laravel 5.2 : Custom Whoops message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Customize the whoops message in Laravel 5.2 | |
* | |
* Convert the given exception into a Response instance. | |
* | |
* @param \Exception $e | |
* | |
* @return \Symfony\Component\HttpFoundation\Response | |
*/ | |
protected function convertExceptionToResponse(Exception $e) | |
{ | |
$statusCode = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 500; | |
switch ($statusCode) { | |
case 404: | |
$title = 'Désolé, la page que vous recherchez n\'a pas pu être trouvée.'; | |
break; | |
default: | |
$title = 'Oups ! Une erreur s\'est produite, contactez l\'administrateur ...'; | |
} | |
$debug = config('app.debug', false); | |
if ($debug) { | |
return parent::convertExceptionToResponse($e); | |
} | |
return response()->view('errors.default', ['exception' => $e, 'title' => $title], $statusCode); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment