in reply to Re: Logging the results of 'die'
in thread Logging the results of 'die'

Most posts in this thread concentrate on how to catch the error message, but I don't think that's the real issue. wog's message touches on it. The eval should put the database handle somewhere so that a cleanup routine can deal with it in case there's an error. You might try something like this:
eval { my $dbh = DBI->connect(..., {RaiseError=>1}); eval { $dbh->do("update ..."); $dbh->do("update ..."); }; if ($@) { # clean up after an unsuccessful update $dbh->rollback(); $dbh->disconnect(); die($@); # reraise the error } # successful update $dbh->commit(); $dbh->disconnect(); }; if ($@) { log($@); }