on 4/30/01 8:47 PM, brian moseley at [EMAIL PROTECTED] wrote:

> On Mon, 30 Apr 2001, Jeffrey W. Baker wrote:
> 
>> type of exception.  Right now I cannot in fact think of
>> any program I have written that branches on the type of
>> exception.  Java encourages this with multiple catch
> 
> in CP Web Mail, the underlying libraries throw typed
> exceptions so that the application layer can display the
> correct error notification to the user. for instance, if the
> library throws CP::InvalidMailboxNameException, Web Mail can
> display 'the mailbox name you suggested contains an illegal
> character. it must correspond to the format thus-and-such.
> try again.', whereas if the library throws CP::Exception
> (the generic exception), Web Mail will handle it as a
> service problem and display that godawful WM9999 page.

I've tried that, but last time I went with more general classes of
exceptions containing unique error IDs (defined in a constants module) to
indicate the exact type.  Not as Java-like, but it did save me from creating
dozens of classes with no unique properties except their names.

I've also tried making separate hierarchies of exceptions for user errors
(illegal input) vs. system errors (can't connect to database).  In those
cases, you usually do switch based on exception class, because the user
errors need to be handled differently.

I suppose it's a matter of debate whether or not bad user input should be
handled with exceptions at all, but since I like to keep the controller code
simple and let the data model objects do the input checking, you have to
bubble it back up somehow.  I'm still kind of unsatisfied with how difficult
some of the user exception handling turned out to be, and I'll probably try
something different next time

- Perrin

Reply via email to