http://www.perlmonks.org?node_id=1061416

techman2006 has asked for the wisdom of the Perl Monks concerning the following question:

I was trying to put a custom handler for the error being raised by SQLite. Below is the snip of the sub routines which I put down.

sub handle_error { my $message = shift; my $database = shift; if ( its a connection error ) { log an error and exit else log an error and continue } sub initDB { my $dbh = shift; my $database = shift; my $driver = "SQLite"; my $dsn = "DBI:$driver:dbname=$$database"; my $userID = ""; my $password = ""; $$dbh = DBI->connect($dsn, $userID, $password, {RaiseError => 1, PrintError => 0, HandleError => \&handle_error, AutoCommit => 0 } ) or handle_error(DBI->errstr, $$database); $$dbh->do("PRAGMA synchronous=OFF"); }

Now is there a way I can identify its an connection error or some other error e.g. say insert operation fails. As I want to use a generic function which take cares of logging the errors based on the error.