Handling HTTP exceptions
When an error occurs in your application, Laravel raises an exception. This is also
true for HTTP errors, as Laravel will raise an appropriate HTTP exception. Usually
when an HTTP error occurs, you will want to display a response informing the user
what went wrong. This is easy in Laravel 5, as all you need to do is create a view
named after the HTTP status code you want it to display for in the
resources/
views/errors
directory.
For example, if you wanted to display a view for 404 Not Found errors, then all you
need to do is create a view at
resources/views/errors/404.blade.php
.
You can use this approach to handle other HTTP errors as well, such as 403 Forbidden
errors; simply create a view at
resources/views/errors/403.blade.php
.
We'll cover views later on in this chapter. In the meantime, you can find a list of HTTP
status codes at
http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
.
Do'stlaringiz bilan baham: |