What's the best way to find out which exceptions may be thrown ?

Mike Parker aldacron at gmail.com
Wed May 27 10:01:33 UTC 2020


On Wednesday, 27 May 2020 at 09:56:07 UTC, wjoe wrote:
>
> The problem with catch(Exception) is that it's run time whereas 
> I'd like to know compile time which exception may possibly be 
> thrown.
>
> So I take it the only way to find out what may be thrown is to 
> read the source code of the called function(s) and the rat tail 
> that follows - and to rely on documentation to be accurate and 
> complete if the source code isn't available.
>
> That's sort of annoying.

Checked exceptions are much more annoying. And without them, 
there's no way (as far as I can see) the compiler can verify what 
a function may throw without parsing the source of every function 
a call chain touches. That's rather impractical.


More information about the Digitalmars-d-learn mailing list