Throwable class design

Jonathan M Davis jmdavisProg at gmx.com
Wed Jan 30 13:07:31 PST 2013


On Wednesday, January 30, 2013 12:40:26 H. S. Teoh wrote:
> On Wed, Jan 30, 2013 at 09:03:31PM +0100, rumbu wrote:
> > Ok, maybe my thoughts are polluted by some C# programming practices,
> > but I learnt that exceptions are never intended for the end user
> > (one of the reasons is that the exception mesages are in most cases
> > displayed in english language). In Windows world, throwing an
> > exception displays a message with a nice two buttons: Close and
> > Debug. This will make the accountant using my software very eager to
> > click on Debug :)
> 
> Maybe that is accepted convention in the Windows world, but I consider
> exceptions as an excellent way of conveying what went wrong to the user.
> Such as "could not calculate cell value, expecting number in cell A5 but
> got 'adfsdfas' instead". Throwing an exception is the cleanest way to
> abort potentially deeply-nested calculation code and give the user a
> useful message in the meantime. I would hate to manually propagate such
> user errors by hand, just because of the convention that exception
> messages should never be seen by the user!

I would never show an exception to a user, even in Linux. I might show the 
exception's message, but I would never let the exception escape and end up 
showing the stack trace and whatnot to the user. I see no problem in showing 
an exception's message to a user if that's what it was intended for. The fact 
that it was an exception which delivered the message is an implementation 
detail that the user doesn't care about and shouldn't know. But I suspect that 
the two of you pretty much agree about that but are thinking of different 
things when you're talking about "showing the exception to the user."

- Jonathan M Davis


More information about the Digitalmars-d mailing list