in reply to Re: Printing DBI errors from a CGI script
in thread Printing DBI errors from a CGI script

... or simply surround the DBI calls with eval()..

my $dbh; eval { ## bunch of dbi calls.. $dbh = DBI->connect( ... ); $dbh->do( blah ); $dbh->commit; $dbh->disconnect; }; if( my $err = $@ ) { eval{ $dbh->rollback }; eval{ $dbh->disconnect }; ## print header, html, and $err exit 1; # or return, whatever }