Php – Custom error page not showing on Laravel 5


I am trying to display a custom error page instead of the default Laravel 5 message :

"Whoops…looks like something went wrong"

I made a lot of search before posting here, I tried this solution, which should work on Laravel 5 but had no luck with it :

Here is the exact code I have in my app/Exceptions/Handler.php file :

<?php namespace App\Exceptions;

use Exception;
use View;
use Bugsnag\BugsnagLaravel\BugsnagExceptionHandler as ExceptionHandler;

class Handler extends ExceptionHandler {

    protected $dontReport = [

    public function report(Exception $e)
        return parent::report($e);

    public function render($request, Exception $e)
        return response()->view('errors.defaultError');


But, instead of displaying my custom view, a blank page is showing. I also tried with this code inside render() function

return "Hello, I am an error message";

But I get same result : blank page

Best Solution

Instead of the response create a route for your error page in your Routes.php, with the name 'errors.defaultError'. for example

route::get('error', [
    'as' => 'errors.defaultError',
    'uses' => 'ErrorController@defaultError' ]);

Either make a controller or include the function in the route with

return view('errors.defaultError');

and use a redirect instead. For example

public function render($request, Exception $e)
    return redirect()->route('errors.defaultError');
Related Question