Todd W. wrote:


<snip>



RTFM for the HandleError property of DBI objects:


http://search.cpan.org/author/TIMB/DBI-1.38/DBI.pm#DBI_Utility_Functions

Scroll down to $h->{HandleError}...

You can set it to a code ref that is called when a DBI exception is thrown.
Read the docs very carefully, you can design arbitrarily complex error
handling for the DBI:

sub DBIErrorHandler {
  my($description, $error) = @_;
  BaseModule::Debug::log(4, "DBI error: $description");
  return( 1 );
}

my($dbh) = DBI->connect( ... );
$dbh->{HandleError} = \&BaseModule::Config::DBIErrorHandler;

It is really slick. For instance, you can chain arbitrary error handlers, or
depending on whether your error handler returns true or false, you can
control the builtin DBI handlers.

The DBI has one of the better error handling mechanisms found on the CPAN.
It should probably be filtered out and made into its own distro.


I had glossed over that in the docs and thought it sounded pretty cool but did not yet have well defined error handling. Now that I do I might just have to go back in and explore it further. Thanks for reminding me (us) of it. Still getting use to the whole DBI thing and haven't had a chance to fully explore it, I was a straight DBD:: user back in the day when I got the start (aka circa 1998...) so much has improved with DBI since then...


http://danconia.org


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to