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

getStack() with no args, for convenience #33

Open
trusktr opened this issue Jul 10, 2020 · 2 comments
Open

getStack() with no args, for convenience #33

trusktr opened this issue Jul 10, 2020 · 2 comments

Comments

@trusktr
Copy link

trusktr commented Jul 10, 2020

It'd be nice if we could get a stack traces without having to instantiate an Error (because sometimes we want a stack traces and instantiating an Error just for that isn't semantic).

f.e. this would be nice:

const stack = getStack()

Instead of

const err = new Error
const stack = getStack(err)

And similar for getStackString.

@mk-pmb
Copy link

mk-pmb commented Jul 10, 2020

I'm torn between my desire for usability, and a desire to keep the spec lean, as this could easily be solved by a transpiler injecting new Error() between the parens, or a very simple library. In any case it should fail loudly if a passed-in variable happens to accidentially be undefined.

@ljharb
Copy link
Member

ljharb commented Jul 11, 2020

getStack(new Error()) doesn't seem particularly burdensome to me; i'm not sure it warrants special handling.

@mk-pmb the methods will throw if anything that lacks an Error internal slot is passed into them.

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