[Exceptional C++ Style] Fw: Item 11: Try and Catch Me

Kevlin Henney kevlin at curbralan.com
Wed Dec 1 06:47:53 EST 2004


In message <1101893112.41ad8df8a99dc at webmail.broadpark.no>, Terje 
Slettebø <tslettebo at broadpark.no> writes
>
>One problem with some implementations of error condition translations (whether
>they are error codes, exceptions, or what), is that they loose too much
>information. I find it rather senseless to get an error something like (very
>common, at least on Windows):
>
>"File doesn't exist, is read-only, or not enough disk space."
>
>I mean, come on, you're the computer; you tell me: Doesn't it exist, is it
>read-only, or isn't there enough disk space? Am I supposed to guess, here?
>
>Same with:
>
>"Can't delete file because it may be in use."
>
>"May"?! Come on... You know it better than me. Could you also tell me _what_ is
>using it, so I may be able to release the file lock?

A common problem with layered exception handling is reinterpreting the 
information flow correctly: you can end being too precise ("Error 1234", 
huh?!) or too vague ("Something bad happened", huh?!) by the time you 
reach the upper levels. It's the Goldilocks principle: too hot, too 
cold, just right -- too much detail, not enough, just right.

I wrote a whole load of stuff in a distributed systems course on this 
topic in the 1990s because with all the layering present in a 
distributed component architecture the problem just becomes amplified.

Kevlin
-- 
____________________________________________________________

   Kevlin Henney                   phone:  +44 117 942 2990
   mailto:kevlin at curbralan.com     mobile: +44 7801 073 508
   http://www.curbralan.com        fax:    +44 870 052 2289
   Curbralan: Consultancy + Training + Development + Review
____________________________________________________________




More information about the Effective-cpp mailing list