Reputation: 169
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
Reputation: 3178
You can customize all error pages in application or create custom listener and inject custom response.
Upvotes: 1
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