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

Support for Error Cause #41

Open
petamoriken opened this issue Oct 3, 2021 · 3 comments
Open

Support for Error Cause #41

petamoriken opened this issue Oct 3, 2021 · 3 comments

Comments

@petamoriken
Copy link

Pony Cause (Error Cause ponyfill) has stackWithCauses function that generate a stack trace string with cause errors. Make sense to add function like System.getStackStringWithCauses.

Error: something really bad happened here: something bad happened
    at Object.<anonymous> (/examples/fullStack.js:5:12)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:968:3
caused by: Error: something bad happened
    at Object.<anonymous> (/examples/fullStack.js:3:12)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:968:3

This feature has nothing to do with compatibility, which is the motivation for this proposal, so it may be better to proceed as a separate proposal. However, I thought it was worth having this issue here for discussion.

related: #22, tc39/proposal-error-cause#16, tc39/proposal-error-cause#41

@ljharb
Copy link
Member

ljharb commented Oct 3, 2021

If engines decide to decorate the stack with causes, then this proposal will have to accommodate it. If not, it won't.

Either way, until this proposal (or another that does the same thing) lands, no proposal would be able to do anything with error stacks. I'm not sure what there is to discuss.

@petamoriken
Copy link
Author

If engines decide to decorate the stack with causes, then this proposal will have to accommodate it. If not, it won't.

Since sentry-javascript and others already assume that Error.prototype.stack does not contain cause errors, it will not be possible to extend it to prevent double printing. Adding it as a separate function is preferable.

Either way, until this proposal (or another that does the same thing) lands, no proposal would be able to do anything with error stacks. I'm not sure what there is to discuss.

That's true. The discussion will start when this proposal (or another) reaches Stage 2 or 3. I prepared for that time. If this issue is in your way, you can close it.

@erights
Copy link
Collaborator

erights commented Oct 4, 2021

Thanks for filing. Please keep it open. The SES-shim currently has a partial shim for getStackString. We will need to update that somehow for causes regardless. Will be good to track that here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants