Bug 18829: (follow-up) Return 404 when record cannot be loaded

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Nick Clemens 2023-03-27 11:53:45 +00:00 committed by Tomas Cohen Arazi
parent b630f66288
commit a730a76069
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
2 changed files with 8 additions and 4 deletions

View File

@ -31,8 +31,8 @@ use Try::Tiny;
# Koha modules used
use C4::Context;
use C4::Output;
use C4::Auth;
use C4::Output qw( output_html_with_http_headers );
use C4::Auth qw(get_template_and_user);
use C4::Biblio;
use C4::ImportBatch;
use C4::XSLT ;
@ -65,8 +65,8 @@ try {
});
}
catch{
@es_fields = ("Error fetching record: see logs for details");
warn $_;
print $input->redirect("/cgi-bin/koha/errors/404.pl");
};
for my $field (sort keys %{$es_record} ){

View File

@ -1738,7 +1738,11 @@ Note that permanent location is a code, and location may be an authval.
$("body").on("click",".previewElastic", function(e){
e.preventDefault();
var pageElastic = $(this).attr("href");
$("#elasticPreview .modal-body").load(pageElastic);
$("#elasticPreview .modal-body").load(pageElastic, function( response, status, xhr ) {
if( status == 'error' ){
$("#elasticPreview .modal-body").html('<h1>An error has occurred!</h1><h2><em>Error 404</em></h2><li>An internal link in the client is broken and the page does not exist</li></ul><h3>What\'s next?</h3><ul style="margin-bottom: 1em; padding-bottom: 1em; border-bottom: 1px solid #CCC;"><li>Use top menu bar to navigate to another part of Koha.</li><li>To report a broken link or any other issue, please contact the Koha administrator. <a href="mailto:[% Koha.Preference('KohaAdminEmailAddress') | uri %]">Send email</a></li></ul>');
}
});
$('#elasticPreview').modal({show:true});
});
[% END %]