Handling errors the smart way
For simple applications immediate death on error is fine
For more advanced applications greater control is needed
Life after death:
$h->{RaiseError} = 1;
eval { … $h->method; … };
if ($@) { … }
Bonus prize
- Other, non-DBI, code within the eval block may also raise an exception that will be caught and handled cleanly
Notes:
eval { } is very cheap: 4.4 microseconds on a SPARC Ultra 5.