Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 use NotFoundException message

Tags:

symfony

In Symfony 2 you can do the following to return a 404 page

throw $this->createNotFoundException('message');

I was assuming that status_text in the error template would display the custom message, but that does not seem to be the case. How can you display the custom message?

Short question, but I dont think this needs more information? Feel free to ask!

like image 431
user2019515 Avatar asked Sep 25 '26 10:09

user2019515


1 Answers

Looking at the show action of ExceptionController you can access the exception inside twig:

{{ exception.message }}

status_text and status_code are related to the HTTP protocol. To customize the error page look at the official documentation.

like image 115
gremo Avatar answered Sep 28 '26 04:09

gremo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!