http://www.perlmonks.org?node_id=799824


in reply to Re^2: Capturing stack trace in eval
in thread Capturing stack trace in eval

Actually, I might have been mistaken about my SIG{__DIE__} assertion - I mean that using __DIE__ instead of overriding CORE::GLOBAL::die might indeed be the best way of dealing with it.

As I said I don't have the code with me at the moment - last time I looked at that specific bit of code was a couple of months ago and I switched implementations a few times.

In any case, the end result turned out that throwing an exception object that encapsulates the stack trace from whatever means you use to intercept the error was the only reasonable way of dealing with the problem when you also have to deal with eval (both versions).

Update: the way I implemented it, was that the exception object overloaded stringification so that the stack trace is printed if the exception isn't eventually caught.