Exception safety
Sergey Gromov
snake.scaly at gmail.com
Fri Dec 12 01:29:25 PST 2008
What happens if an extern(Windows) function throws?
Basically I want my export DLL interface functions to fail gracefully.
What happens if I don't catch? Currently my typical export looks like
this, and it looks a bit verbose:
extern(Windows) export HRESULT DllRegisterServer()
{
try
{
doStuff();
}
catch(Exception e)
{
myTrace("Shit happens. Reason: " ~ e.msg);
return E_UNEXPECTED;
}
catch(Object obj)
{
myTrace("Shit happens. Reason: " ~ obj.toString());
return E_UNEXPECTED;
}
catch
{
myTrace("Shit happens. Reason: unknown");
return E_UNEXPECTED;
}
return S_OK;
}
More information about the Digitalmars-d
mailing list