Checked vs unchecked exceptions

mckoder via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 27 18:35:32 PDT 2017


On Tuesday, 27 June 2017 at 22:56:47 UTC, Moritz Maxeiner wrote:
>
> You mean the very first time you want to call it and you don't 
> know the exception set yourself by looking at its signature?
> Put the call in a nothrow scope and compile the module (which 
> is fast in D), the compiler will then complain which exceptions 
> you didn't catch (requires improvement of nothrow analysis [1]).
>

So to know what exceptions are possible you have to compile the 
code? I consider that inferior to other solutions such as callee 
explicitly stating what exceptions it may throw, because then all 
you have to do is glance at the callee. Also, I think explicitly 
stating your intent in this manner (by the callee not just the 
caller) is a good idea, to make sure you are not throwing some 
exception you didn't mean to throw.



More information about the Digitalmars-d mailing list