-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add an error response event handler to set correct Content-Type header #29 #32
Conversation
As \Drupal\jsonapi\EventSubscriber\DefaultExceptionSubscriber we need to supply our own handler for error responses. Unlike jsonapi there are no strict rules about the content of error responses set by OpenReferral standard, so we can just encode the Drupal repsonse in JSON and set the header.
@ekes is this something we need to let Open Referral know about? Am thinking they could make some modifications to the way they handle errors |
No. The OpenReferral spec is fine. It (the parent spec) gives guidance about the HTTP error codes to return. It then leaves it free to put whatever into the content section (explicitly discussed here openreferral/api-specification#3 ) The error on our end is because our tests have started checking the Content-Type that we were returning errors with - and we were serving them as text not json - which was wrong on our side - because of the missing handler. |
…tests. Used in the error handling service @Serializer is supplied by serialization.
Good to know. Cheers for the info |
Simple test fix for Open Referral in Directories will remove that last fail localgovdrupal/localgov_directories#184 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ekes. The failing test is in the localgov_directories_or module which should be fixed with localgovdrupal/localgov_directories#186
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge away!
As \Drupal\jsonapi\EventSubscriber\DefaultExceptionSubscriber we need to
supply our own handler for error responses. Unlike jsonapi there are no
strict rules about the content of error responses set by OpenReferral
standard, so we can just encode the Drupal repsonse in JSON and set the
header.
Tests are already covered by the present tests that are on upgrade failing.