June 23, 2017 at 5:24 pm

Custom ‘Not found HTTP exception’

When you start doing routing and add some rules, in the beginning it’s easy to make a lot of mistakes. Because I didn’t want others to see the output laravel throws on the screen I decided to start looking for a solution to add custom error pages. In Laravel 5 you can get this done by going into app- Http - Kernel.php.

Here you should add the following to make sure the right class is called and a Response object can be made.

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Response;

Once inside the handle function we should also add a new catch to make sure the NotFoundHttpException will be caught correctly. This will load the view errors/missing which I made as my style error page.

catch (NotFoundHttpException $e)
    return Response::view('errors.missing', [], 404);
0 likes error , laravel 5
Share: / / /