1

When using the following Laravel helper function in a view:

abort( 404 );

Instead of displaying the default Laravel 404 error page, I'm getting:

Symfony\Component\HttpKernel\Exception\NotFoundHttpException

Stack Trace:

public function abort($code, $message = '', array $headers = [])

{

    if ($code == 404) {

        throw new NotFoundHttpException($message);

    }

    throw new HttpException($code, $message, null, $headers);

}

How can I get abort( 404 ); to display the stock Laravel 404 error page?

3
  • 3
    How come you're using it in a view and not the route callback/controller method? Commented Mar 11, 2021 at 20:46
  • 1
    That was it, thank you. I needed to call abort( 404 ) from my controller method instead of a view. Commented Mar 11, 2021 at 22:10
  • 2
    Never perform any logic in a view Commented Mar 11, 2021 at 22:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.