Throwable class design

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Jan 30 13:19:52 PST 2013


On Wed, Jan 30, 2013 at 04:07:31PM -0500, Jonathan M Davis wrote:
> 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."
[...]

Ah, the hilarity of English ambiguity... I meant "display the exception
message", of course. Uncaught exceptions with stack traces in any
application are Very Bad(tm).


T

-- 
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it. -- Brian W. Kernighan


More information about the Digitalmars-d mailing list