[Detroit-pm] Trying to get a handle on exceptions

Scott Webster Wood treii28 at yahoo.com
Thu May 22 12:36:28 PDT 2008


Yeah, I guess that's an option - I just don't like to use eval in web based apps for the most part.  I figured there was probably some better way of handling it out there.

SW

----- Original Message ----
From: Joe Landman <landman at scalableinformatics.com>
To: Scott Webster Wood <treii28 at yahoo.com>
Cc: detroit-pm at pm.org
Sent: Thursday, May 22, 2008 3:29:58 PM
Subject: Re: [Detroit-pm] Trying to get a handle on exceptions

Scott Webster Wood wrote:
> OK, so you got this nifty little config file reader that reads some company's legacy config file format much better than their old scripted perl stuff did.  But when you made it, you were smart enough to put some error conditions that would either 'die' or 'croak' with Carp when things occurred that would prevent it from doing anything further (file not found, file not readable, etc) as well as the occasional carp that complains about things it finds that aren't quite kosher.
> 
> So you did it with a typical perl oop:
> 
> use readcfg;
> my $cfg = new readcfg(-cfgfile => 'somefile.cfg');

Out of curiousity, couldn't you:

    use readcfg;
    my $cfg;

    eval { $cfg = new readcfg(-cfgfile => 'somefile.cfg'); };

    if ($@)
     {
      # danger Will Robinson, handle the exception
     }
     else
     {
      # all is well in configuration land ...
     }

> 
> ....

I seem to remember doing something like this in DBIx::SimplePerl and others.

-- 
Joseph Landman, Ph.D
Founder and CEO
Scalable Informatics LLC,
email: landman at scalableinformatics.com
web  : http://www.scalableinformatics.com
        http://jackrabbit.scalableinformatics.com
phone: +1 734 786 8423
fax  : +1 866 888 3112
cell : +1 734 612 4615



      


More information about the Detroit-pm mailing list