redo graphapierrorexception #222
Open
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.
this removes wrong
GraphApiErrorExceptionparsing logic and improves its fault toleranceremove incorrect GraphApiError parsing
my previous implementation was wrong. the graph api error docs are a bit wage and i must have missed the link to the more detailed explanation. previously this could result in failure to create the exception.
now it only tries to parse the outer most required fields. the complete error object is additionally stored as a
JSONObject. this greatly simplifies parsing and printing, which currently are the only use cases for this information anyway.prevent exceptions during GraphApiErrorException creation
previously if there was an issue parsing the error response, an exception would be thrown, loosing the status code and cluttering the stack trace.
now it will always create the exception, simply noting a parsing failure in its message.
remove Response constructor from GraphApiErrorException
Response.bodymay return null and the exception would need to handle that.the caller however, does most likely have context to determine if it would be null or not. potentially passing a custom json string that would provide more info than a generic 'was null'.
it also prevents potential double reads of the body, which are not supported.
use case-insensitive JSON parsing in GraphApiErrorException
the docs use inconsistent capitalization for the json keys. so this change was made to make parsing more tolerant in case this is real world behavior.
since case insensitive lookup may be something thats useful elsewhere, it was put in a separat JsonUtil file.
OneDrive cleanup
uploadToSessionhad become quite large, so i took the opportunity to move accept and error handling into separate functionsprint output examples
invalid json:
with inner error: