From a22cfca01aa816a027727f4caf00394dfe92834e 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 --- C4/Biblio.pm | 2 ++ Koha/Exceptions.pm | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 140eb2200b..f74bbe80ad 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.20.1