Storage::DBI error reporting improvement from Dan Sully
Matt S Trout [Sat, 1 Apr 2006 00:10:06 +0000 (00:10 +0000)]
lib/DBIx/Class/Storage/DBI.pm

index 7058f0b..efefa1a 100644 (file)
@@ -481,8 +481,11 @@ sub _execute {
   @bind = map { ref $_ ? ''.$_ : $_ } @bind; # stringify args
   my $rv;
   if ($sth) {
-    $rv = $sth->execute(@bind)
-      or $self->throw_exception("Error executing '$sql': " . $sth->errstr);
+    $rv = eval { $sth->execute(@bind) };
+
+    if ($@ || !$rv) {
+      $self->throw_exception("Error executing '$sql': ".($@ || $sth->errstr));
+    }
   } else {
     $self->throw_exception("'$sql' did not generate a statement.");
   }