The Right Approach to Exceptions

Jonathan M Davis jmdavisProg at
Mon Feb 20 10:20:01 PST 2012

On Monday, February 20, 2012 18:05:38 foobar wrote:
> Separation of concerns - exceptions are meant to notify the
> *developer* of errors. User facing error messages is a separate
> concern that exceptions should not be responsible for. it's not
> just outsourcing the translation strings, it's the developer's
> job to determine what if at all should be done with the exception.

Agreed. Users shouldn't be seeing exception messages. They are intended for 
the developer. Users don't know or care about them. You don't display error 
codes to users when something goes wrong do you?

The point of exceptions is to allow the _program_ to react appropriately. In 
some cases, that means printing out a message to the user or popping up a 
dialogue. In many, it doesn't. We need exceptions to give the program the 
information that it needs to programmatically react to what went wrong, not 
print a nice, internationalized error message. And adding an 
internationalization mechanism would actually make things _worse_, because it 
complicates exceptions for something that they don't generally need, and it 
makes debugging harder, because you can't see the message as easily in the 

The fields and functions that exceptions have should be geared towards 
facilitating the program processing and recovering from the exception, not 
printing out error messages. And a big part of that is giving them fields which 
can be processed programmatically, not ways to print internationalized 

- Jonathan M Davis

More information about the Digitalmars-d mailing list