Internal server errors are good, user feedback is better.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tiny change: removed the obsolete 'use Koha::Exceptions'.
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
use C4::Biblio;
use Koha::Authority::Types;
use C4::Biblio;
use Koha::Authority::Types;
use Koha::MetadataRecord::Authority;
my $input = new CGI;
use Koha::MetadataRecord::Authority;
my $input = new CGI;
push @errors, { code => 'DESTRUCTIVE_MERGE' };
} else {
my $recordObj1 = Koha::MetadataRecord::Authority->get_from_authid($authid[0]);
push @errors, { code => 'DESTRUCTIVE_MERGE' };
} else {
my $recordObj1 = Koha::MetadataRecord::Authority->get_from_authid($authid[0]);
- Koha::Exceptions::ObjectNotFound->throw( "No authority record found for authid $authid[0]\n" ) if !$recordObj1;
+ if (!$recordObj1) {
+ push @errors, { code => "MISSING_RECORD", value => $authid[0] };
+ }
+
my $recordObj2;
if (defined $mergereference && $mergereference eq 'breeding') {
my $recordObj2;
if (defined $mergereference && $mergereference eq 'breeding') {
} else {
$recordObj2 = Koha::MetadataRecord::Authority->get_from_authid($authid[1]);
}
} else {
$recordObj2 = Koha::MetadataRecord::Authority->get_from_authid($authid[1]);
}
- Koha::Exceptions::ObjectNotFound->throw( "No authority record found for authid $authid[1]\n" ) if !$recordObj2;
+ if (!$recordObj2) {
+ push @errors, { code => "MISSING_RECORD", value => $authid[1] };
+ }
+
+ unless ( $recordObj1 && $recordObj2 ) {
+ if (@errors) {
+ $template->param( errors => \@errors );
+ }
+ output_html_with_http_headers $input, $cookie, $template->output;
+ exit;
+ }
+ if ($mergereference ) {
my $framework;
if ( $recordObj1->authtypecode ne $recordObj2->authtypecode && $mergereference ne 'breeding' ) {
my $framework;
if ( $recordObj1->authtypecode ne $recordObj2->authtypecode && $mergereference ne 'breeding' ) {
The Default framework cannot be used, or the framework does not exist. Please select another framework for merging.
[% ELSIF error.code == 'EMPTY_MARC' %]
Sorry, but we did not find any MARC tags in the reference record.
The Default framework cannot be used, or the framework does not exist. Please select another framework for merging.
[% ELSIF error.code == 'EMPTY_MARC' %]
Sorry, but we did not find any MARC tags in the reference record.
+ [% ELSIF error.code == 'MISSING_RECORD' %]
+ Sorry, but we did not find a record for number: [% error.value %].
[% ELSE %]
[% error %]
[% END %]
[% ELSE %]
[% error %]
[% END %]