Feature idea: scope (failure, ExceptionSpecification) for catching exceptions

Andrej Mitrovic via Digitalmars-d digitalmars-d at puremagic.com
Sat Mar 28 03:15:33 PDT 2015


On 3/26/15, Vladimir Panteleev via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> What is your use case for only logging specific exception types?

We already have scope(failure) with its defined semantics (it will not
swallow the exception), changing that would be bad. So the only
workable solution I see is to extend it via 'scope(failure,
ExceptionType ex)'.

It's not that I want to catch specific exceptions, but instead I
really love using scope but often find myself wishing I could catch
the exception, swallow it (not rethrow it) and log it, without a
try/catch.

Sometimes you're not allowed to propagate an exception (think nothrow
functions, functions that interact with C, functions invoked in
different threads, etc), so you have to try/catch and use logging. I
kind of think extending scope could make this nicer to work with.

It was just a passing thought, though. :)


More information about the Digitalmars-d mailing list