Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom ExceptionWrapperHandler seems to be ignored #926

Closed
ilterra opened this issue Dec 19, 2014 · 2 comments
Closed

Custom ExceptionWrapperHandler seems to be ignored #926

ilterra opened this issue Dec 19, 2014 · 2 comments

Comments

@ilterra
Copy link

ilterra commented Dec 19, 2014

Hi,
my app throws an exception like:

throw new HttpException( 400, 'My custom message' );

I expect the response to be:

{"error":{"code":400,"message":"My custom message"}}

but I get:

{"error":{"code":400,"message":"Bad Request"}}

I tried to customize the error message with an ExceptionWrapperHandler, defined as:

fos_rest:
    view:
        exception_wrapper_handler: AppBundle\Handler\ExceptionWrapperHandle

but this declaration seems to be ignored. Am I missing something?

Thanks

@lsmith77
Copy link
Member

we have a configuration setting to determine for what exceptions we expose the message, which is handled in the ExceptionController:
https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Controller/ExceptionController.php#L174

see here for the docs:
https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Resources/doc/4-exception-controller-support.md

@lsmith77
Copy link
Member

I made some changes here .. its now also possible to configure a service:
#942

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants