Laravel has class called ‘app\Exceptions\Handler’ to handle all the exceptions. This class has two methods as report and render.
report() method is used to log exception and also used to send log exceptions to external services like Sentry, Bugsnag etc.
render() method is used to render an exception into an HTTP response, which will be sent back to browser.
Beside these two methods, the app\Exceptions\Handler class contains an important property called “$dontReport”. This property takes an array of exception types that will not be logged.
Some exceptions describe HTTP error codes like 404, 500 etc.
The abort() method would be used to generate such response anywhere in an application, as follows.
Laravel has simple and easy process to use the custom error pages for each separate error codes.
For example, to design custom page for error code 404, you can create a view at resources/views/errors/404.blade.php. Same way, if you want to design error page for error code 500, it should be stored at resources/views/errors/500.blade.php.
Step 1 − Add the following lines in app/Http/routes.php.
Step 2 − Create a view file called resources/views/errors/404.blade.phpand copy the following code in that file.
Step 3 − Visit the following URL to test the event.
Step 4 −We will see the following output
Laravel Related Interview Questions
|Python Interview Questions||PHP Interview Questions|
|Zend Interview Questions||AJAX Interview Questions|
|MySQL Interview Questions||Drupal Interview Questions|
|WordPress Interview Questions||Java Abstraction Interview Questions|
|Phonegap Interview Questions||wxPython Interview Questions|
|PHP7 Interview Questions|
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.