Replace exception handler?
Ali Çehreli
acehreli at yahoo.com
Thu Feb 27 14:24:21 PST 2014
On 02/27/2014 05:24 AM, Remo wrote:
> Unfortunately I can not find a way to replace exception handler in D2.
> Is there a way to do this?
I think you mean the unhandled exception handler. Otherwise, try+catch
is the way to provide a handler. ;) I think that would not be the
solution as it would kick in when the application (druntime?) was going
down; hence it would be too late anyway.
> The problem is that I load a Dll coded in D from Application coded in
C++.
> If this Dll throw and exception then there is no way to handle it from
> the Application.
One way is to wrap every API function in a try+catch block on the dll
side and return an error code and message. Not very pretty. :-/
Further, there may be a thin C++ layer that converts the error code and
message to a C++ exception so that the C++ code need not deal with error
codes. (I would definitely do this.)
> Application will crash without any way to figure out where the D
> exception was thrown.
One solution for that is to log a stack trace at the point of exception
construction. We used libunwind in a C++ project but I haven't done
anything similar in D.
Ali
More information about the Digitalmars-d-learn
mailing list