Sub-classing exceptions

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 16 20:32:23 PDT 2015


On 10/16/15 10:35 PM, Shriramana Sharma wrote:
> Jacob Carlborg wrote:
>> If you declare the subclass as usual you can have a template mixin that
>> adds the constructor.
>>
>> class SubException : Exception
>> {
>>       mixin ExceptionConstructors;
>> }
>
> Hmmm is that in any way advantageous to what I wrote about it? Is it just
> that you can now add a doc-comment that DDoc can recognize?
>

You can add other members to your custom exception class. If you wanted 
for instance to have some specialized toString function, or extra data, 
you could add. With yours, only simple derived types can be created.

-Steve


More information about the Digitalmars-d mailing list