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

Re: Attempting to trap a DBI->connect error

by mifflin (Curate)
on Jan 06, 2007 at 03:46 UTC ( #593262=note: print w/ replies, xml ) Need Help??


in reply to Attempting to trap a DBI->connect error

By default DBI does not throw exceptions.
If you want it to you need to use the 4th argument to pass in a hashref telling it to do so like...

my $dbh = DBI->connect('db conn info here','userid','password',{RaiseE +rror => 1});
This will force DBI to throw errors with a die that you must catch with an eval.
This will also have the effect of making your code cleaner looking as you will not have to check for errors after every prepare, bind, execute, fetch... etc method you call. Just make sure you catch the errors.


Comment on Re: Attempting to trap a DBI->connect error
Download Code
Re^2: Attempting to trap a DBI->connect error
by Hammy (Scribe) on Jan 07, 2007 at 16:57 UTC
    Thank you very much for the insight, I will give this a try.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (17)
As of 2014-07-23 14:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (144 votes), past polls