-
-
Notifications
You must be signed in to change notification settings - Fork 895
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
Allow defining exception_to_status per operation #3519
Allow defining exception_to_status per operation #3519
Conversation
0c89695
to
7d8b503
Compare
7d8b503
to
1aec872
Compare
1aec872
to
2b5ab9b
Compare
Thank you for your PR! |
Sure, see api-platform/docs#1309. |
@alanpoulain I updated |
ce4acdb
to
7b83475
Compare
Yes, it will be OK like this! |
7b83475
to
dd746c7
Compare
dd746c7
to
3e5ab24
Compare
Thank you @julienfalque. |
Thank you @alanpoulain. |
This PR allows introduces the
exception_to_status
attribute in operations and resources mapping.The use case is when some domain exception should be transformed into a specific HTTP status on some API endpoints, but not on others.
For example: a method in some entity throws a
NotPossible
exception when called through an API endpoint. You want that endpoint to return a400 Bad Request
. But if the same entity method throws that exception when called from unrelated internal code, maybe that's actually an error in the code and should result in a500 Internal Server Error
.