🐛 AddError should support all instances of type Error #3228
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.
Motivation
Recently, all errors of type AxiosError stopped logging properly. Instead of the standard log with Error object, it was serializing the error object instead.
After some investigation I tracked down the regression to #3144 - which changes the object type check from
param instanceof Error
toObject.prototype.toString.call(error) === '[object Error]'
. Unfortunately, the way AxiosError is created, that toString call just produces[object Object]
. However, theinstanceof
check works just fine.Changes
I've addressed the regression by using both the original
instanceof Error
check as well as the newtoString
check. Supporting both checks cover both the old and the new feature requirements.Testing
I spent some time trying to get the tests running - but I was not successful. I don't doubt there might be some tweaks required in the PR, but I think the bulk of it is complete. Please feel free to modify the PR as needed. Hopefully this can get fixed quickly and we can all have AxiosError logging working again.
I have gone over the contributing documentation.