Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Thinking about module error handling

by Tanktalus (Canon)
on Jun 13, 2005 at 22:46 UTC ( #466314=note: print w/replies, xml ) Need Help??

in reply to Thinking about module error handling

Stages of error handling:

  1. Hey, this is easy - just grab the return code, and use it...
    $rc = func(); if ($rc != 0) { die "Failed to func!"; }
  2. Oh, neat! Exceptions!
    eval { func(); } if ($@) { die "Failed to func: $@"; }
  3. Exceptions/OO are da bomb! Look at this!
    use Error::Handler; $rc = func(); if (not $rc->ok()) { die $rc->error_msg(); }
  4. Damn, that's way too much work...
    $rc = func(); if ($rc != 0) { die "Failed to func!"; }

At least, that's my experience...

Replies are listed 'Best First'.
Re^2: Thinking about module error handling
by sgifford (Prior) on Jun 14, 2005 at 00:04 UTC
    That's similar to my experience, which is why this module is API compatible with (1) and (4). On top of that simple and ubiquitous interface, it adds a way to find out more details about the error if the application programmer wants it---like $! but more general.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://466314]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2019-12-08 20:31 GMT
Find Nodes?
    Voting Booth?

    No recent polls found