Adding Custom Exception Views to Laravel

There are a number of views already created in Blade for when exceptions occur but as you might expect, you can alter these to be just how you require.

Editing the files directly is possible, but there is a better way which only takes a minute.

Let’s start by creating a blank project

Wait for that to finish and then run the in-built server so that you can see your shiny new website.

Great! Now let’s generate an exception. We can do this easily by placing the site into maintenance mode so go ahead and do that now.

Go back to your home page URL and see the exception being shown in a view.

Now time to change it. Open up the file:

We aren’t going to change this – just select all the text and copy it into the clipboard.

Next, create a file in resources/views/errors named: 503.blade.php. Note, you may have to create the errors folder.

Paste the text in that you copied and alter the message:

Before:

After:

Save this and revisit the homepage of your Laravel website. Tada!

twitterredditpinteresttumblrmail

Written by Stephen Moon
email: stephen at logicalmoon.com
www: https://www.logicalmoon.com


Hey! Did you enjoy reading this? If you did and would like an email when I add new content, just subscribe to my list. You can unsubscribe at any time.


Leave a Reply

Your email address will not be published. Required fields are marked *