Handling errors the smart way
Life after death:
$h->{RaiseError} = 1;
eval {
foo();
$h->method; # fails so the DBI calls die
bar($h); # may also call DBI methods
};
if ($@) {
... handle the error here ...
}
Bonus prize:
- Other, non-DBI, code within the eval block may also raise an exception that will be caught and can be handled cleanly