The idea is simple: a rethrow key word to use inside catch blocks. This would cause errors that are re-thrown to be thrown as if from their original location, so as to not disrupt the error stack.
For example:
try {
// ...
} catch (e) {
if (!(e instanceof SomeSpecificError)) rethrow e // make it behave as it would have normally
// ... handle special error ...
}
The idea is that the error would behave exactly as if it was thrown from its original location before try catch would have intercepted it, as if there never were a try catch.
Currently, when we re-throw errors using throw, the stack trace that dev tools shows will not be exactly as where the error originated, but will include the new throw location (can be confusing).
@JackWorks the developer tools can however pause both in the location where it is thrown the first time (if break on caught exceptions is enabled) and in the location where it is re-thrown (if break on exceptions is enabled).
Dev tools can choose whatever behavior they like; regardless, a stack trace (which is what the OP described) is never generated from throwing - only from creating a new error object.
I suppose it is the devtools behavior that is not ideal. Maybe the spec can address that; that's what the rethrow idea was for. I do see that if I inspect the error.stack I see the original stack. But devtools shows me other stuff based on where an error is re-thrown.
Essentially what I was hoping for is a way to cause the try-catch to behave as if it was never there.
Hmmm, you're right, nvm, not sure what I saw. Was it always like that? Maybe an async stack threw me off; but that only adds to the stack when expanded, it looks like.