PoC: Implemented Repository to REST Exception converters #63
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
v4.6
Ibexa REST defines a few of its own Exception classes and API Exception wrapper classes. In order for an API Exception to be rendered correctly as a response, it needs to be either wrapped with REST Exception which has its own Visitor or actually have dedicated Visitor. If we look at
./src/bundle/Resources/config/value_object_visitors.yml
we will find a mix of those approaches.Instead of trying to cover both REST and Repository API exceptions with one or two separate visitors, I suggest a new idea: Repository Exception converter which would map a Repository Exception into its REST counterpart.
As an example,
ContentFieldValidationExceptionConverter
, has been implemented to properly map Repository APIContentFieldValidationException
to RESTContentFieldValidationException
. This allows the following simplification of REST Controllers:Before:
After:
Paths to explore
TODO
Checklist:
$ composer fix-cs
).