On Sun, 18 Sep 2005 01:43:42 -0500, Peter Rabbitson wrote:

> I am trying to incorporate cleaner exception handling in my code. Here 
> is a small illustration (meaningless) of what most of my code looks 
> like:
[...]
> I then tried to change it in the following way, but I get an error:
> Can't locate object method "catch" via package "DBException" (perhaps 
> you forgot to load "DBException"?) at ./testerror line 16.
[...]
> package Databank;
> use strict;
> use warnings;
> use Error qw(:try);
> 
> sub get_values {
> 
>     #fail right away
>     throw DBException ("Sorry, bank is empty");
> }
> 

Each exception needs to be a class that inherits from Error, so:

        BEGIN { @DBException::ISA = 'Error' }

-- 
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to