gouseferoz
10 months ago
107
4
Laravel

Getting 500 error codes instead of 404 when edited the exception handler file.

Posted 10 months ago by gouseferoz

Hi All,

In the exceptions\handler.php code, I have changed the render function to this:

public function render($request, Exception $exception)
    {
        $guard = array_get($exception->guards(), 0);

        switch($guard)
        {
            case 'admin':
                return redirect('/admin/login');
                break;
            default:
                return redirect('/login');
                break;
        }
        return parent::render($request, $exception);
    }

which is causing the server to show 500 error instead of 404 error for the pages that were not routed in web.php file.

What should be done here to get the actual 404 errors instead of 500

Regards, Feroz

Please sign in or create an account to participate in this conversation.