Python
Python

Reputation: 169

Symfony NotFoundHttpException don't throw my message

I try to throw a 404 exception with a specific message like that :

throw new NotFoundHttpException($error);

The problem is that it doesnt display the error message which is in the var $error. It display the message : Oops! An Error Occurred

The server returned a "404 Not Found".

Can you help ?

Upvotes: 2

Views: 1145

Answers (2)

ZhukV
ZhukV

Reputation: 3178

You can customize all error pages in application or create custom listener and inject custom response.

Upvotes: 1

miko7358
miko7358

Reputation: 1101

If you are in a controller, try to use throw $this->createNotFoundException($error);

If you are in a service I think (in your case) you should create a custom listener to the kernel.exception event.

Upvotes: 0

Related Questions