From b0c39296c5c557bfcb00a762036bb269efd04a46 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 29 Sep 2020 13:29:49 +0200 Subject: [PATCH] Bug 26518: Raise exception if the insert failed Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- C4/Biblio.pm | 2 ++ Koha/Exceptions.pm | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 44428156d5..3fe8b38716 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -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 ); diff --git a/Koha/Exceptions.pm b/Koha/Exceptions.pm index cf56b220ef..eec3baaa14 100644 --- a/Koha/Exceptions.pm +++ b/Koha/Exceptions.pm @@ -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' -- 2.39.5