Asserts inside nothrow function
Sean Kelly
sean at invisibleduck.org
Sat May 23 09:31:55 PDT 2009
Denis Koroskin wrote:
> I just started using nothrow functions a little bit and came across the
> following issue.
> Some of the functions that I'd like to mark as nothrow have debug
> asserts inside them.
>
> They used to throw an Exception, but I'd like to change their behavior
> and terminate an application whenever an assertion fails inside a
> nothrow function.
At the moment, any exception that passes beyond user control will result
in that thread terminating rather than the entire app. This goes for
the main thread also--if you have other threads running then the app
won't exit until those complete as well. I suppose I could add an
"unhandled exception handler" that lets the user specify what should
happen, though the only options are really either letting only the
thread terminate or calling exit() to terminate the entire app. The
only advantage of a handler over setting a boolean for behavior is that
you could do custom error reporting and the like as well. There's no
harm in providing such a feature, so I think I'll look into it for 2.031.
More information about the Digitalmars-d
mailing list