The Right Approach to Exceptions
doob at me.com
Tue Feb 21 23:22:21 PST 2012
On 2012-02-21 22:08, Andrei Alexandrescu wrote:
> On 2/21/12 2:42 PM, Jacob Carlborg wrote:
>> On 2012-02-21 21:27, Andrei Alexandrescu wrote:
>>> On 2/21/12 2:26 PM, Jacob Carlborg wrote:
>>>> As I said, it seems you want to push up implementation details specific
>>>> to a given subclass to the base class even though it shouldn't be
>>> I explained that doing so allows for proper formatting of error
>>> messages. So it should pushed up.
>> Well, I don't think that is the right approach. As many others have
>> explained, error messages are only a small part of exception handling.
> I agree. Also, one interface function is only a small part of a class
>> If you do want to have a generic way of getting an error message out of
>> an exception, what's wrong with toString? Or a new method that formats
>> the error messages. No need to push up the instance variables to the
>> base class.
> This has been answered in the long thread. In brief, toString loses too
> much information and putting formatting inside exceptions is not the
> right place.
Now I'm completely lost. According to what I've read this is thread this
is exactly what you want to do, put the formatting inside the exceptions.
More information about the Digitalmars-d