# Picking up the Pieces

- ## So, what went wrong?

  $@
  - holds the text of the error message
  if ($DBI::err && $@ =~ /^(\S+) (\S+) failed: /)
  - then it was probably a DBI error
  - and $1 is the driver class (e.g. DBD::foo::db), $2 is the name of the method (e.g. prepare)
  $DBI::lasth
  - holds last DBI handle used (not recommended for general use)
  $h->{Statement}
  - holds the statement text associated with the handle (even if its a database handle)

- ## $h->{ShowErrorStatement} = 1

  - appends $h->{Statement} to RaiseError/PrintError messages:
  - DBD::foo::execute failed: duplicate key [for ``insert ]
  - for statement handles it also includes the $h->{ParamValues} if available.
  - Makes error messages much more useful. Better than using $DBI::lasth
  - Many drivers should enable it by default. Inherited by child handles.

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