-
Notifications
You must be signed in to change notification settings - Fork 739
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
fix(exceptionhandler): Remove exception handler from the controller s… #1018
Conversation
srekapalli
commented
Jan 21, 2020
- Remove exception handler from the controller since we have a generic handler in Kork.
- Since we have dup. exception handlers, anything that gets wired up last will be used in processing that exception and in this particular scenario it was logging messages related to this controller though they were not related to keel.
…ince we have a generic handler in Kork
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.
thank you!
does the generic ExceptionHandler from kork have the same behaviour of propagating the retrofit exception (status/headers/content)? if not and if we want to preserve the existing API behaviour then we could wrap the keel API calls with something that catches RetrofitException and wraps it (KeelRetrofitException?) and re-throws, and update this ExceptionHandler to that specific exception |
it does look like this will change the behaviour: it looks like it is just doing a sendError with the HTTP status code |
Via HasAdditionalAttributes in GenericErrorController the new behaviour would be to end up encoding the responseBody as a |
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.
It is good to know that I broke something when adding this functionality for keel. @srekapalli could you maybe update the normal gate error handling to actually pass the error information through to the user?
I added this functionality so that when we threw good error messages in keel they would actually show up to the user.
Sounds good. Will address the response/exception handling to match what we had. |
@emjburns : If keel sends the errors with JSON content type, GenericExceptionHandler will preserve the response received and sends it back to the caller in the If we need to send the error response as body to the caller we need to raise some special exceptions and handle it that way. But IMO, it's better to stick to our generic error handling scheme and have callers look at body attribute of the error response payload. |
I believe Keel's error responses will use either |
@emjburns / @robfletcher : If we fallback to our generic exception handler to serialize the Retrofit error, we send the below response to the caller and caller need to look at the body attribute to parse out the actual body returned. If this is acceptable, I would like to merge this PR. Just a sample response from my unit test: { |
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.
That sounds fine. When I added this the errors weren't getting propagated successfully. I'm ok with you merging this in and maybe you can help if things aren't working still :)