Catch exception from external library

Jonathan M Davis jmdavisProg at gmx.com
Thu Aug 11 00:07:44 PDT 2011


On Thursday, August 11, 2011 06:53:57 Callum Anderson wrote:
> Hi,
> 
> Is there any way to catch unhandled exceptions thrown by external libraries?
> I am calling an external C library function, which works fine in release
> mode, however in debug mode it throws a SIGSEV. I would like to debug later
> parts of the code, but can;t get past this function when debugging because
> of the exception.
> 
> I have tried putting the function call in try/catch, tried a scope(failure)
> and tried collectException() from std.exception. Is it possible to catch
> these exceptions?

SIGSEV is a signal, not an exception. No exception handling code will do 
anything with it. And pure c code _can't_ throw exceptions of any kind, 
because C has no exceptions (it _might_ be possible for an exception to come 
out of C code which called code from another language which _does_ have 
ecxeptions, but I'm not sure). If you want to handle SIGSEGV, you need a use a 
signal handler.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list