However, mostly people leave the DBI on it's default settings, which carp() errors before you ever get to the "or" part of your statement.While I don't know what people normally do, the DBI default is for some unexplicable reason to not do that: (from the docs):
"RaiseError" (boolean, inherited)Update: just to be clear: the parent node's comments about $! and $dbi->errstr are correct, it's just that the default DBI setting is to use those, and not throw exceptions. If you want to automatically get an exception on a database/SQL error (and I suggest you should), you need to use the RaiseError option on the DBI->connect call.The "RaiseError" attribute can be used to force errors to raise exceptions rather than simply return error codes in the normal way. It is "off" by default. -snip-
update2: jettero is correct in his correction, but we both seem to agree that you should use RaiseError to catch any further errors. The chances of anything unexpected going wrong later without notice are a lot higher if you don't.
In reply to Re^2: error catching
by Joost
in thread error catching
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |