purescript/purescript-exceptions

Add a `stack` accessor?

hdgarrood opened this issue · 3 comments

ie, stack :: Error -> String, that just reads the stack property. There's no agreed-upon format but according to MDN all modern browsers support it, and I'm pretty sure it's always a String.

I thought we already had this, but actually it's just used in the show instance when available:

exports.showErrorImpl = function (err) {
return err.stack || err.toString();
};

Ah ok - come to think of it, perhaps it should be Error -> Maybe String, then. There might be a purity issue with this too; it wouldn't surprise me if you could violate some expectation if you wrote a program that changed behaviour based on an error's stack. Although I think access to stack traces is probably useful enough that we needn't worry, and people are probably only going to use them while debugging anyway.

👍