Trailing catch on function?

Mike Parker via Digitalmars-d digitalmars-d at puremagic.com
Mon Nov 7 18:50:10 PST 2016


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.

I recall a proposal somewhere for something like scope(exit, e), 
where 'e' is a Throwable instance. That would be great for 
logging the exception message, but unless it also allowed for 
aborting the throw, it still wouldn't be useful in this specific 
case.


More information about the Digitalmars-d mailing list