in reply to Re^2: DB Error Handling Not Working
in thread DB Error Handling Not Working

sowais:

If the error is cleared by the disconnect call, then pull the disconnect out of the block and put it after the end of the eval block. If you feel you need similar error checking for the disconnect, wrap that in its own eval block.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^4: DB Error Handling Not Working
by sowais (Sexton) on Aug 20, 2014 at 15:46 UTC
    sorry, didn't realize i was logged out for the earlier post.. Tried that but eval didn't capture it. Against my better judgement I put in a 'die' statement next to the execute statement and that seems to work! I would prefer not to have an error handler within an error handler but unfortunately I've burned way too much time troubleshooting 'eval's failrue to capture the error.
    eval { $dbh = DBI->connect("dbi:ODBC:$DSN"); ... $sth->execute() or die "Execute Failed: $!"; $dbh->disconnect(); }; if($@) { print "DB Failure: $@"; }