'Use Laravel's default error pages as supposed to custom created ones

I have implemented custom error pages in my Laravel project but now run in to a situation where I actually want to fallback on displaying the default ones. The application consists of an admin area and 'front' area. I created the custom error pages for the front area but want to fall back on the default ones for the admin area.

The request comes in via the app\Exceptions\Handler.php, render() method which calls its parent render() method in vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php. I'm kind of stuck at the convertExceptionToResponse() method within this class which seems to be called in case of a custom template but not in case of a default template.

Can you guys help me out?



Solution 1:[1]

I figured it out thanks to this post Is it possible to create separate error pages for the backend and frontend in laravel?

What I did was copy the dafault error pages to the subfolder /admin, we probably will customize them in the future anyway.

protected function getHttpExceptionView(HttpExceptionInterface $e)
{
    if (isAdminPage()) {
        return "errors.admin.{$e->getStatusCode()}";
    }

    return "errors::{$e->getStatusCode()}";
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rik Verbeek