Error.pm and try/catch/throw

F

fishfry

Is Error.pm the standard way to do error handling these days? Or at
least *a* standard way?

Are there any standard or popular libraries of exceptions, or should I
just write my own Error.pm subclasses?
 
F

fishfry

fishfry said:
Is Error.pm the standard way to do error handling these days? Or at
least *a* standard way?

Are there any standard or popular libraries of exceptions, or should I
just write my own Error.pm subclasses?

No responses? I was just curious to know what kind of error handling
people do. It seems to me that the try/catch/throw method is an
improvement to the old days of checking error returns and trying to pass
the right amount of error detail info upstairs to callers. I know how to
use eval and die handlers.

Do most serious Perl programmers use one method or another of handling
errors, and if so, what?
 
S

SMO

fishfry said:
No responses? I was just curious to know what kind of error handling
people do. It seems to me that the try/catch/throw method is an
improvement to the old days of checking error returns and trying to pass
the right amount of error detail info upstairs to callers. I know how to
use eval and die handlers.

Do most serious Perl programmers use one method or another of handling
errors, and if so, what?

FWIW I use try/catch/throw exception handling via a custom wrapping of
Error.pm

MS
 
R

Richard Gration

No responses? I was just curious to know what kind of error handling
people do. It seems to me that the try/catch/throw method is an
improvement to the old days of checking error returns and trying to pass
the right amount of error detail info upstairs to callers. I know how to
use eval and die handlers.

Do most serious Perl programmers use one method or another of handling
errors, and if so, what?

I use eval and a custom error object. The main problem I have with this is
that the eval is at the top level and so any module error messages which
don't provide a line number in the caller (as is the case with
DBD::Sybase) can be difficult to trace. Otherwise it works well. I define
some error codes in my Error object and trapping specific errors can be as
simple as

die MyApp::Error->new(<errorcode>) unless (...);

Also unforseen errors get trapped by the eval. $@ is a string not an
object when that happens, but is easily remedied.

Rich
 
R

Ron Savage

On Thu, 21 Jul 2005 15:54:02 +1000, fishfry wrote:

Hi Fishy

If you search the archives of (I think) mod_perl's mailing list you'll seeError
has been repeatedly criticised. The alternative recommended isException::Class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top