Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: Re: The art of error handling

by jreades (Friar)
on Dec 20, 2000 at 00:55 UTC ( [id://47460]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: The art of error handling
in thread The art of error handling

The system I have tried to use across the Web site I control, and which I have found particularly useful for DBI work, is:

return($success_ref, $error_ref);

Each subroutine returns either

$dbh->prepare($query) || return (0, "Error: " . $dbh->errstr);

or

return ($array_ref, 0);

You can pepper these throughout your code anywhere there's a DBI action able to fail and it ensures that you can fail somewhat gracefully.

It's not perfect, but it also makes error-checking easy (just test whether $errors contains anything) and allows you to develop a cascading series of calls where it doesn't bother executing subsequent queries if one has already failed.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-25 21:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found