-
-
Notifications
You must be signed in to change notification settings - Fork 11k
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
Adding HTTP status code to error.toJSON #2956
Conversation
After submitting this PR did I realise that there is 123 (at time of writing) open PR's on this project awaiting integration. Is it safe to say this one likely won't be merged in anytime soon? |
Hi, I will review soon. We are trying to release a v0.20 as soon as possible. |
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.
Good job!
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 perfect for v0.20.0
Hello! 👋 \n\nThis pull request is being automatically marked as stale because it has not been updated in a while. Please confirm that the issue is still present and reproducible. If no updates or new comments are received the pull request will be closed in a few days. \n\nThanks |
Can this please be merged? We have hacks in multiple places to fix this. thx :) |
@emilyemorehouse @jasonsaayman |
* Adding HTTP status code to error.toJSON (axios#2947) * Adding Error display div to internal server client.html Co-authored-by: Jay <jasonsaayman@gmail.com>
Issue Summary
Previously it was reported in #2947 that the Axios
error.toJSON()
was not outputting the HTTP status code.For example;
would result in the following error message that did not have the HTTP status code of 404 instead only containing the code in the nested in the error
message
string (such as "Request failed with status code 404").The Fix
With the following addition to the
toJSON
function's return object inenhanceError.js
:the response HTTP status code will be added when a response is available. If no response is available (i.e. we can't derive a HTTP status code), we will use
null
as the value to imply it is intentionally unavailable.Failing Test without addition
createError.spec.js (existing test-class) (test-amendment)
enhanceError.spec.js (existing test-class) (new test)
Passing Test with addition
Execution specifically on the
*Error.spec.js
testsExecution with
npm test
Side Note: Cannot seem to run these in Safari. When it launches the karma runner, it opens the Safari browser with a Choose file modal already focused to a redirect.html. Also it hangs running on Opera which I don't believe I have installed. When I sigkill, testing moves on to the the bundlesize test
Internal client.html addition
Additionally, I've added a display to the internal client.html which is started using
npm start
.This now displays the result of an error in the main display (under an Error div) that uses
toJSON()
as well as displaying the error object in the console.No Error
On startup

Successful response / no error

Error
With a 404 error
