Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Thinking about module error handling

by Tanktalus (Canon)
on Jun 13, 2005 at 22:46 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2024-04-23 11:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found