Thoughts about exception reporting

pineapple via Digitalmars-d digitalmars-d at puremagic.com
Fri Feb 3 11:50:19 PST 2017


Something I keep going back and forth on is the best way to 
handle exception reporting in different contexts. There are so 
many idioms to use here and none of them feel quite ideal. I'm 
not sure the best way to improve it, but I'm hoping a discussion 
might produce some useful ideas.

Some suggestions, apart from the obvious "exceptions shouldn't 
require the gc":

- nothrow might be repurposed to mean "doesn't throw recoverable 
exceptions", and it not forbid throwing objects that inherit from 
Error. It's limiting to have to use asserts to report 
nonrecoverable errors in nothrow code, rather than specialized 
error classes that might provide better information as to what 
went wrong.

- pure might no longer prevent code from throwing `static const` 
objects, so that error reporting can still be done using @nogc 
and user-defined error classes in pure functions. It's 
unintuitive that asserts and `throw new WhateverError` should be 
allowed, but not `static const error = new WhateverError; throw 
error`.


More information about the Digitalmars-d mailing list