On 8 November 2016 at 12:50, Mike Parker via Digitalmars-d < digitalmars-d@puremagic.com> wrote:
> On Tuesday, 8 November 2016 at 01:50:26 UTC, Walter Bright wrote: > >> On 11/7/2016 4:12 PM, Robert burner Schadek wrote: >> >>> On Monday, 7 November 2016 at 23:37:18 UTC, Walter Bright wrote: >>> >>>> void callback() nothrow >>>> { >>>> scope (failure) >>>> { >>>> ...log error or abort... >>>> } >>>> ...lots of code... >>>> } >>>> >>> >>> Who to get the Exception thrown in the scope(failure) >>> >> >> You don't. The exception is also rethrown, so it isn't an exact >> replacement. (The 'nothrow' is a mistake on my part.) >> > > In this specific case, a function used as a callback for a C API, it > really ought to be nothrow because of the inconsistent behavior with > propagating exceptions across language boundaries. scope(exit) just isn't > useful here. > It's not strictly useful for interaction with C, it would be equally useful in the situation where a nothrow function returns an error code or something. The tail-catch block could do the translation and return the error, and it would be in a nice place separate from the main function body.