Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

fix: error reporting for non-JSON responses #1016

Merged
merged 8 commits into from
May 21, 2019
Merged

Conversation

alanshaw
Copy link
Contributor

@alanshaw alanshaw commented May 21, 2019

Better error reporting by detecting Content-Type of the response and not attempting to parse JSON for non-application/json responses.

resolves #912
resolves #1000
closes #1001

KrishnaPG and others added 8 commits May 21, 2019 21:30
Better error reporting in case of `json.parse` failures
Making the `parseError` function compatible with non-JSON responses from server.
   - `isJson = true` parameter added that is backwards compatible with existing code

Ref: #1000 (comment)
`parseError` method should print default error in case data is null or empty ("")

Co-Authored-By: Alan Shaw <alan.shaw@protocol.ai>
This makes `parseError` more self-sufficient.
  35:1   error    Trailing spaces not allowed   no-trailing-spaces
This is needed for the callers to know when the error needs a retry (such as 401, 403 etc.
Uses `statusCode` since `code` is being used in JSON responses.

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
@alanshaw
Copy link
Contributor Author

PR build is failing because of commit lint in earlier commits. Branch build is passing. Lets get this merged! Thanks again @KrishnaPG

@alanshaw alanshaw merged commit 4251c88 into master May 21, 2019
@alanshaw alanshaw deleted the KrishnaPG-patch-1 branch May 21, 2019 21:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSON.parse(data) errors Better handling for unexpected responses
2 participants