how to tell whether we are running inside a try/catch block?

Timothee Cour thelastmammoth at gmail.com
Sun Oct 27 06:24:15 PDT 2013


On Fri, Oct 25, 2013 at 7:16 AM, Ali Çehreli <acehreli at yahoo.com> wrote:

> On 10/25/2013 04:12 AM, Timothee Cour wrote:
>
> > the stack would already be unwinded and there'd be no way to go back in
> time
> > to the point where the relevant exception got thrown.
>
> Another spot is the constructor of the exception. We print the stack
> contents by libunwind in a C++ project. (Never tried in D.)


The problem with this approach is 2-fold:
* it requires modifying how each exception is constructed
* it doesn't know where the exception will be caught so you'd launch the
debugger at every thrown exception instead of at one location which gathers
all uncaught exceptions

I've actually worked out a solution that works great, see my post:
"proposal(+working code): catch block callback before stack unwinds to
allow attaching debugger"

it doesn't affect any try/catch blocks except the ones we specify; the key
is to put the logic as annotation at the catch block, not at the thrown
exception.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20131027/b22365aa/attachment.html>


More information about the Digitalmars-d-learn mailing list