Open
Description
Is your feature request related to a problem? Please describe.
The error stack trace is created when the error instance is constructed, not where it is thrown.
Atm, we fix this by overriding the error instance's stack trace at thrown time.
Describe the solution you'd like
If we take a class instead, we can just instantiate the class and then expect that the error instance is constructed. Even more general would be a function returning an error instance...
This will make the stack trace start from where it is thrown. But we may still need to "reset" it according to the decorated function, as that will give us a cleaner trace... but it assumes we don't need to know exactly where it is thrown. It's a bit more "magical".
I'm already trialling this out in the timed
decorator and other context decorators.