slightlyoff / Promises

DOM Promises IDL/polyfill
Apache License 2.0
154 stars 28 forks source link

Clean up exception stack-traces #57

Closed cowwoc closed 11 years ago

cowwoc commented 11 years ago

I like Future.then()-style callback chaining but it has the nasty side-effect of mangling exception stack-traces in a way that makes code harder to debug.

Is it possible for the implementation to programmatically rewrite the stack-trace so Future.then(A).then(B).then(C) ends up with a stack-trace that reads C -> B -> A instead of C -> Future.wrap -> Future.pump -> anonymous function -> anonymous function?

slightlyoff commented 11 years ago

I don't think it's possible to re-write them, as far as I know. This is something I'm hoping we'll get devtools support for, and I know @wycats is in contact with Pavel about similar needs for skipping/tracing things. Since I don't konw that there's anything I can do here, I'm going to close this ticket.

cowwoc commented 11 years ago

What prevents you from rewriting Error.stack? It's just a string that you can easily rewrite. Yes, browsers will handle this natively in the future but in the meantime Promise.js can act as a polyfill.