X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FRecord.pm;h=6b05d2dac3d3ee0f4b87e1c9dd16b02f89851a1a;hb=678a99d01de1bd98dd49110d3862d173918fc9b8;hp=71cc69ca9031a61ffd1d9f6a1618589a02496a48;hpb=162706c35d0523d437038fbb28dfe626ac0252f4;p=freeside.git diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 71cc69ca9..6b05d2dac 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -1871,7 +1871,13 @@ sub batch_import { while ( scalar(@later) ) { my $sub = shift @later; my $data = shift @later; - &{$sub}($record, $data, $conf, $param); # $record->&{$sub}($data, $conf); + eval { + &{$sub}($record, $data, $conf, $param); # $record->&{$sub}($data, $conf) + }; + if ( $@ ) { + $dbh->rollback if $oldAutoCommit; + return "can't insert record". ( $line ? " for $line" : '' ). ": $@"; + } last if exists( $param->{skiprow} ); } next if exists( $param->{skiprow} ); @@ -1902,9 +1908,12 @@ sub batch_import { } - $dbh->commit or die $dbh->errstr if $oldAutoCommit;; + unless ( $imported || $param->{empty_ok} ) { + $dbh->rollback if $oldAutoCommit; + return "Empty file!"; + } - return "Empty file!" unless $imported || $param->{empty_ok}; + $dbh->commit or die $dbh->errstr if $oldAutoCommit;; ''; #no error