-
Notifications
You must be signed in to change notification settings - Fork 21
Add additional error information #10
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
Conversation
…ception BREAKING CHANGE: The response is no longer stored in the service exceptions
…ssage from service response
I quickly looked at the PR and have 2 questions
|
Good questions. I just made some changes so here are the answers:
|
IIRC, this is the set of properties that needs to be commonized across all the languages, per https://github.ibm.com/arf/planning-sdk-squad/issues/818 |
Yep, those are the ones @padamstx. I'll send a message out about those now and we can hold off on merging this if you want until we get that coordinated. |
@lpatino10 some services like Discovery return an |
I think we can go ahead and merge this PR now. We just need to remember to update the other core packages to use the same common set of response property names. |
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.
Looks good. Just one comment to think about.
String responseString = ResponseUtils.getString(response); | ||
try { | ||
final JsonObject jsonObject = ResponseUtils.getJsonObject(responseString); | ||
if (jsonObject.has(MESSAGE_ERROR)) { |
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 might be cleaner if the various MESSAGE_ERROR* constants were just a String[] where the elements are an ordered list of the property names that we'll look for. Then the various if/elseif/.../else blocks would become a loop over the elements in the array and we just bail out after finding the first match. This way, when (and I mean when) the list of properties changes, it will be easy to change them :)
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 does sound cleaner. I'll make that change along with (maybe) the one to handle the new error spec.
@germanattanasio are you talking about this spec?: https://pages.github.ibm.com/CloudEngineering/api_handbook/design/errors.html Taj just sent me that and I'm not sure if we have other SDKs specifically handling it. We can add that for the major release though. |
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.
looks good
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.
LGTM
Regarding:
I have complained about this design, which is actually the recommended approach in the API Handbook, since I first saw it. I think this form of error response is wrong-headed. The rationale is that there could be multiple errors and we should report all of them on the response. But then how do we convert this into a meaningful error that software can process? cc: @jsstylos |
An issue was submitted a while back where users using a certain API couldn't retrieve a
correlation_id
field in their error response due to the way we were handling and wrapping errors. This field was particularly important for support people trying to resolve errors.This PR changes the main exception class
ServiceResponseException
to handle parsing for error messages, which used to be done inWatsonService
it also changes what is provided for the user, removing the rawResponse
object in favor ofmessage
(the parsed error message) anddebuggingInfo
, which is aMap
of the rest of the response.A test has been added to validate the debugging information.