-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Make the malformed response error message debuggable #4177
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
Codecov Report
@@ Coverage Diff @@
## master #4177 +/- ##
=======================================
Coverage 92.21% 92.21%
=======================================
Files 116 116
Lines 8089 8089
=======================================
Hits 7459 7459
Misses 630 630
Continue to review full report at Codecov.
|
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
@@ -191,7 +191,11 @@ function wrapToHTTPRequest(hook, key) { | |||
try { | |||
body = JSON.parse(body); | |||
} catch (e) { | |||
err = { error: "Malformed response", code: -1 }; | |||
err = { |
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.
does the e: SyntaxError have any useful info?
think this is worth unit testing??
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.
The case i'm trying to cover here isn't actually bad JSON it's when you don't have JSON at all and the text reads "Socket closed because not https" or something like that. We could also provide the e.toString() or e.message though for when there is a problem with the json formatting (but I think that is much less common since these are usually machine serialized results.
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.
makes sense...
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.
This is definitely useful but feels sloppy, any other ideas on how to make this better @acinader?
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.
I wouldn't over think it. adds good feedback on an error. I approved it cause I think it's mergeable.
It would be nice if this error message contained some or all of the malformed response to aid in debugging the problem. What do you think?