# Catching the Exception

- ## Life after death

  $h->{RaiseError} = 1;
  eval {
  foo();
  $h->method; # if it fails then the DBI calls die
  bar($h); # may also call DBI methods
  };
  if ($@) { # $@ holds error message
  ... handle the error here …
  }

- ## Bonus

  - Other, non-DBI, code within the eval block may also raise an exception
  - that will also be caught and can be handled cleanly

## .

Previous slide | Next slide | Back to first slide | View graphic version