Reece Hart > Bio-Prospect-1.04 > CBT::Exception

Download:
Bio-Prospect-1.04.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

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

SYNOPSIS ^

 package MyModule::Exception;
 use base CBT::Exception;

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

DESCRIPTION ^

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

error is a short (1 line) description of the problem. Consider using $! if nothing else.

detail (optional)

detail provides more details about the nature of the problem. The contents of this field are word-wrapped.

advice (optional)

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

ROUTINES & METHODS ^

::new( {error=>..., detail=>..., advice=>...} )
::new( error, detail, advice )

creates a new exception with the spe

SEE ALSO ^

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

AUTHOR ^

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