Skip to content
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

Add original error property #2010

Closed
1 task done
rightaway opened this issue Mar 11, 2022 · 5 comments · Fixed by #2327
Closed
1 task done

Add original error property #2010

rightaway opened this issue Mar 11, 2022 · 5 comments · Fixed by #2327
Labels
enhancement This change will extend Got features ✭ help wanted ✭

Comments

@rightaway
Copy link

What problem are you trying to solve?

@szmarczak asked me to create a separate issue (#1865 (comment)).

Could you add a property on the got Error object like original that stores the original Error if there was one for example from socks-proxy-agent? It would really help with more involved error handling scenarios.

Describe the feature

More background is at #1865.

The cause property could be used https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#differentiate_between_similar_errors since it is standard.

Checklist

  • I have read the documentation and made sure this feature doesn't already exist.
@sindresorhus
Copy link
Owner

Yeah, we should use cause for all our errors. I guess we could use https://github.com/voxpelli/pony-cause for now until we target Node.js 16.

@szmarczak szmarczak added enhancement This change will extend Got features ✭ help wanted ✭ labels Mar 11, 2022
@rightaway
Copy link
Author

@sindresorhus If the original error goes under a cause property in Node less than 16 without using a package like that will it cause a problem? Isn't it backwards compatible to just add a new property?

@sindresorhus
Copy link
Owner

If we just add a new property, it won't be included in the .stack.

@rightaway
Copy link
Author

If nothing would break for people using Node 15 then maybe cause could be added without that package. Node 16 get the better stack and Node 15 things work as before.

@voxpelli
Copy link

Its Node 16 time 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This change will extend Got features ✭ help wanted ✭
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants