From: Brandon L. Black Date: Thu, 31 May 2007 19:22:37 +0000 (+0000) Subject: _execute throws execptions as opposed to returning undef, so check errors that way X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8e08ecc45c955c65bc829a2d260ad9bd5b3e173c;p=dbsrgits%2FDBIx-Class-Historic.git _execute throws execptions as opposed to returning undef, so check errors that way --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index cdfc1ee..24b3333 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -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; }