Not sure how this is done in Laravel 5. In 4 you could add in App::error(function(Exception $exception, $code){} block to the routes.php file, and it would serve as a blanket exception handler. I get how it works in Laravel 5 where you add handling for individual exceptions and custom exceptions, which is great - but is there a sort of "Catch all" handling mechanism as well?
1 Answer
You would probably need to have to customize the render() method of App\Exceptions\Handler, as stated here : http://laravel.com/docs/5.0/errors#handling-errors
You can edit the app/Exceptions/Handler.php to do the job :
public function render($request, Exception $e) { //Your code here return view('error'); } 3 Comments
coleman-benjamin
Okay, thanks just clicked in... what it returns in the end is what's important. I was seeing examples that check what the instance of the exception is, and thinking every exception would have to be handled individually, but in the end whatever doesn't get handled specifically will wind up at the last return. Thanks!
Manan
Yeah, since every exception extends the
Exception class, you need not run any instaceOf checks if you want a catch-all system.Emeka Mbah
Just to mention, ensure you know what you are doing because you might start getting blank page when your application encounters an error, if you do mess up handler.php