From c66c3922a85dad2c2db74e663cc0476ace1398ab Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sun, 4 Aug 2019 10:47:02 -0500 Subject: [PATCH] Bug 23425: Display the MARCXML error in the Metadata::Invalid exception message Signed-off-by: Tomas Cohen Arazi --- Koha/Biblio/Metadata.pm | 5 ++++- Koha/Exceptions/Metadata.pm | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Koha/Biblio/Metadata.pm b/Koha/Biblio/Metadata.pm index 9da2ec2b49..bbc11d9d87 100644 --- a/Koha/Biblio/Metadata.pm +++ b/Koha/Biblio/Metadata.pm @@ -68,11 +68,14 @@ sub record { if ( $self->format eq 'marcxml' ) { $record = eval { MARC::Record::new_from_xml( $self->metadata, 'utf-8', $self->schema ); }; + my $marcxml_error = $@; + chomp $marcxml_error; unless ($record) { Koha::Exceptions::Metadata::Invalid->throw( id => $self->id, format => $self->format, - schema => $self->schema + schema => $self->schema, + marcxml_error => $marcxml_error, ); } } diff --git a/Koha/Exceptions/Metadata.pm b/Koha/Exceptions/Metadata.pm index d9f55efd56..887a49e5db 100644 --- a/Koha/Exceptions/Metadata.pm +++ b/Koha/Exceptions/Metadata.pm @@ -25,7 +25,7 @@ use Exception::Class ( 'Koha::Exceptions::Metadata::Invalid' => { isa => 'Koha::Exceptions::Metadata', description => 'Invalid data', - fields => ['id','format','schema'] + fields => ['id','format','schema', 'marcxml_error'] } ); @@ -36,8 +36,8 @@ sub full_message { unless ($msg) { if ( $self->isa('Koha::Exceptions::Metadata::Invalid') ) { - $msg = sprintf( "Invalid data, cannot decode object (id=%s, format=%s, schema=%s)", - $self->id, $self->format, $self->schema ); + $msg = sprintf( "Invalid data, cannot decode object (id=%s, format=%s, schema=%s, MARCXML error='%s')", + $self->id, $self->format, $self->schema, $self->marcxml_error ); } } -- 2.23.0