dao icon indicating copy to clipboard operation
dao copied to clipboard

Saving exception's stack trace when re-raising

Open Night-walker opened this issue 10 years ago • 0 comments

When catching exceptions, you may sometimes need to re-raise them. For instance, when you determine that this exceptions cannot actually be handled at this point. Or when exception handler is supposed to do some side job, like logging, without suppressing exceptions.

There is just a single minor problem. When you re-raise exception, information about the context in which it was raised -- stack trace -- is lost, being substituted by the current context. Given that Dao provides no interface to extract that information, you won't be able to find out where re-raised exception was initially raised.

I suppose this can be fixed by tying exception object to its stack trace and providing way to preserve the trace when exception is re-raised.

Night-walker avatar Mar 10 '15 10:03 Night-walker