Bug 26518: Raise exception if the insert failed

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2020-09-29 13:29:49 +02:00
parent a1e9453f1d
commit b0c39296c5
2 changed files with 6 additions and 0 deletions

View File

@ -240,6 +240,7 @@ sub AddBiblio {
}
)->store;
$biblionumber = $biblio->biblionumber;
Koha::Exceptions::ObjectNotCreated->throw unless $biblio;
my ($cn_sort) = GetClassSort( $olddata->{'biblioitems.cn_source'}, $olddata->{'cn_class'}, $olddata->{'cn_item'} );
my $biblioitem = Koha::Biblioitem->new(
@ -276,6 +277,7 @@ sub AddBiblio {
agerestriction => $olddata->{agerestriction},
}
)->store;
Koha::Exceptions::ObjectNotCreated->throw unless $biblioitem;
$biblioitemnumber = $biblioitem->biblioitemnumber;
_koha_marc_update_bib_ids( $record, $frameworkcode, $biblionumber, $biblioitemnumber );

View File

@ -18,6 +18,10 @@ use Exception::Class (
isa => 'Koha::Exceptions::Exception',
description => 'The required object doesn\'t exist',
},
'Koha::Exceptions::ObjectNotCreated' => {
isa => 'Koha::Exceptions::Exception',
description => 'The object have not been created',
},
'Koha::Exceptions::CannotDeleteDefault' => {
isa => 'Koha::Exceptions::Exception',
description => 'The default value cannot be deleted'