Instantiating Whoops in the render method doesn't work quite like it did in 5.1. The render method in Laravel's exception handler actually handles a number of default exceptions for you, like the validation HTTP exception or the ModelNotFoundException. In these instances you might actually want the page to render with the validation errors or the 404, so it's better to let them be handled that way. Instead, you can override the method in app/Exceptions/Handler.php that generates the Symfony exception response and instead use Whoops.
/**
* Create a Symfony response for the given exception.
*
* @param \Exception $e
* @return mixed
*/
protected function convertExceptionToResponse(Exception $e)
{
if (config('app.debug')) {
$whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
return response()->make(
$whoops->handleException($e),
method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 500,
method_exists($e, 'getHeaders') ? $e->getHeaders() : []
);
}
return parent::convertExceptionToResponse($e);
}
That is handled by a different part of the exception handler, and should be done before a Whoops page is built. If a HttpException with a status code of 500 is thrown, and the errors.500 view exists then it should be presented. If the view does not exist, the exception will be passed on to the method above to handle it.
Hey there, I used this code in Laravel 5.3. I've got the Problem, that Validation Errors still get rendered with whoops instead of redirecting with errors! Any ideas how to solve this?