Scope failure is not preventing application crush in case of uncaught exceptions
ketmar
ketmar at ketmar.no-ip.org
Sat Dec 16 21:28:33 UTC 2017
kerdemdemir wrote:
> On Saturday, 16 December 2017 at 20:56:26 UTC, ketmar wrote:
>> kerdemdemir wrote:
>>
>>> As far as I know scope(failure) should be collecting all failure cases.
>>
>> nope. `failure` scope won't stop exception propagation, it is just
>> called before exception leaves your function, to give you a last chance
>> to do some immediate cleanup.
>
> Than do I still need to catch'em all? For me it doesn't matter the which
> exception it is. It is more important for me to not pollute my code with
> so many exception related lines. What is the most compact way for me to
> catch'em all?
see collectException[0], for example. something like (WARNING! DON'T DO
THIS! it's not wise to silence everything! try to be selective with
`collectException!RequiredExceptionType` instead!)
collectException(() {
your code here
}());
or just move your code to some function, and do
collectException(myfunction);
[0] http://dpldocs.info/experimental-docs/std.exception.collectException.2.html
More information about the Digitalmars-d-learn
mailing list