The Right Approach to Exceptions

Nick Sabalausky a at a.a
Mon Feb 20 16:09:39 PST 2012


"foobar" <foo at bar.com> wrote in message 
news:rsfpoesjcefsiwxoxgzm at forum.dlang.org...
> On Monday, 20 February 2012 at 20:18:58 UTC, Nick Sabalausky wrote:
>> "foobar" <foo at bar.com> wrote in message
>> news:uphvtoqkvtshnzlqoaus at forum.dlang.org...
>>>
>>> I meant -
>>> what's the benefit of:
>>> throw createEx!AcmeException("....");
>>> vs.
>>> throw new AcmeException("....");
>>>
>>
>> Fixed.
>
> Huh? <confused>
>

You forgot the "new" in the second example. I make that mistake in my own 
code all the time :)

>
> I just want to add to the above valid points one comment:
> instead of the proposed inheritCtors D could e perhaps modified to make 
> ctors more uniform with other methods. ctors could be automatically 
> inherited if sub class does not define its own ctors and does not add new 
> fields.
>
> the above would simply become:
>
> class AcmeException : Exception {} // inherits super ctors automatically
>

I often forget that doesn't already happen. I think what confuses me is that 
non-inherited classes implicitly define "this(){}" if there's no other ctors 
(Which is very handy though. Haxe doesn't do that which I always find 
irritating).




More information about the Digitalmars-d mailing list