_execute throws execptions as opposed to returning undef, so check errors that way
Brandon L. Black [Thu, 31 May 2007 19:22:37 +0000 (19:22 +0000)]
lib/DBIx/Class/Storage/DBI.pm

index cdfc1ee..24b3333 100644 (file)
@@ -913,11 +913,13 @@ sub insert {
   my $ident = $source->from; 
   my $bind_attributes = $self->source_bind_attributes($source);
 
+  eval { $self->_execute('insert' => [], $source, $bind_attributes, $to_insert) };
   $self->throw_exception(
     "Couldn't insert ".join(', ',
       map "$_ => $to_insert->{$_}", keys %$to_insert
-    )." into ${ident}"
-  ) unless ($self->_execute('insert' => [], $source, $bind_attributes, $to_insert));
+    )." into ${ident}: $@"
+  ) if $@;
+
   return $to_insert;
 }