Created
February 20, 2016 15:04
-
-
Save lukepolo/328d8231d4d36aeb6569 to your computer and use it in GitHub Desktop.
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
/** | |
* Create a Symfony response for the given exception. | |
* | |
* @param \Exception $e | |
* @return mixed | |
*/ | |
protected function convertExceptionToResponse(Exception $e) | |
{ | |
if (config('app.debug')) { | |
$whoops = new Run(); | |
if(\Request::ajax()) { | |
$whoops->pushHandler(new JsonResponseHandler()); | |
} else { | |
$whoops->pushHandler(new PrettyPageHandler()); | |
} | |
return response()->make( | |
$whoops->handleException($e), | |
method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 500, | |
method_exists($e, 'getHeaders') ? $e->getHeaders() : [] | |
); | |
} | |
return parent::convertExceptionToResponse($e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment