With Laravel 5.5 It is extreemly easy to create custom Error Pages.

For example if you wish to customize your 404 Status Code Error Page.

Create a new file resources / views / errors / 404.blade.php

This file will be used to serve all the not found pages in your application.

<h2>Not Found !!</h2>

<p>Sorry The Page you are looking for does not exist in this application.</p>

 

[caption id="attachment_1011" align="aligncenter" width="750"]Custom-404-Laravel Custom 404 Laravel[/caption]

 

You can also make use of abort exceptions message on the page. If you are aborting the user in your code to throw them custom exception, something like

abort(404, "A Custom Exception Message");

Then, you can make use of the exception message in your error page

 

<h2>{{ $exception->getMessage() }}</h2>

 

Similary you can create custom Error pages for other exceptions like 401, 500 etc.

Comments