
CBT::Exception -- base class for exceptions $Id: Exception.pm,v 1.2 2003/05/12 22:24:00 rkh Exp $

package MyModule::Exception;
use base CBT::Exception;
package MyModule;
...
if ($failed)
{ throw MyModule::Exception; }
...

CBT::Exception is a base class for exceptions. It may be used as-is or as a base class for other exceptions. It is based on Error.pm with enhancements for providing more informative feedback and run-time control of feedback levels.
At the time of this writing, one really needs two components to use exceptions: 1) an exception class, 2) the language extensions which enable the try...catch...finally syntax. This module provides a base class for (1); `use CBT::Exceptions' for (2).
A CBT::Exception instance has these attributes:
error is a short (1 line) description of the problem. Consider using $! if nothing else.
detail provides more details about the nature of the problem. The contents of this field are word-wrapped.
advice provides advice about how to rememdy the error. The contents of this field are word-wrapped.
When thrown, a CBT::Exception looks like this:
! MyModule::Exception occurred: invalid argument Detail: you provided 0 for your IQ; the valid range is 1..10 Advice: soak your head

creates a new exception with the spe

Error.pm -- where all the hard work's done

Reece Hart E<lt>reece@in-machina.comE<gt> http://www.in-machina.com/~reece/