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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: SQLite handling of errors through common function
by daxim (Curate) on Nov 06, 2013 at 12:35 UTC | |
by techman2006 (Beadle) on Nov 06, 2013 at 14:56 UTC | |
Re: SQLite handling of errors through common function
by mje (Curate) on Nov 06, 2013 at 17:16 UTC | |
by techman2006 (Beadle) on Nov 07, 2013 at 08:27 UTC | |
by mje (Curate) on Nov 07, 2013 at 11:04 UTC | |
by techman2006 (Beadle) on Nov 07, 2013 at 12:39 UTC | |
by mje (Curate) on Nov 07, 2013 at 14:09 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |
Back to
Seekers of Perl Wisdom