From dce8be16c399e8fe61c29c07c5b4dc85139db72e Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Wed, 30 Jul 2014 09:26:38 -0400 Subject: [PATCH] LP 1350345: marc_export blows up on bad records. Add some eval blocks around calls to MARC::Record->as_usmarc and MARC::Record->as_xml_record to trap errors in bibliograpic and authority records. If MARC::Record reports an error, print the record id and the error message and continue the export. Signed-off-by: Jason Stephenson Signed-off-by: Ben Shum --- Open-ILS/src/support-scripts/marc_export.in | 40 +++++++++++++++++---- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/support-scripts/marc_export.in b/Open-ILS/src/support-scripts/marc_export.in index 7f24a3d74f..348c4b3a6f 100755 --- a/Open-ILS/src/support-scripts/marc_export.in +++ b/Open-ILS/src/support-scripts/marc_export.in @@ -509,10 +509,24 @@ sub next { } } if ($Marque::config->option_value('format') eq 'XML') { - $output = $marc->as_xml_record; - $output =~ s/^<\?.+?\?>$//mo; + eval { + $output = $marc->as_xml_record; + $output =~ s/^<\?.+?\?>$//mo; + }; + if ($@) { + print STDERR "Error in bibliograpic record " . $r->id() . "\n"; + print STDERR "$@\n"; + return $self->next(); + } } else { - $output = $marc->as_usmarc; + eval { + $output = $marc->as_usmarc; + }; + if ($@) { + print STDERR "Error in bibliograpic record " . $r->id() . "\n"; + print STDERR "$@\n"; + return $self->next(); + } } } return $output; @@ -755,10 +769,24 @@ sub next { } } if ($Marque::config->option_value('format') eq 'XML') { - $output = $r->as_xml_record; - $output =~ s/^<\?.+?\?>$//mo; + eval { + $output = $r->as_xml_record; + $output =~ s/^<\?.+?\?>$//mo; + }; + if ($@) { + print STDERR "Error in authority record " . $r->id() . "\n"; + print STDERR "$@\n"; + return $self->next(); + } } else { - $output = $r->as_usmarc; + eval { + $output = $r->as_usmarc; + }; + if ($@) { + print STDERR "Error in authority record " . $r->id() . "\n"; + print STDERR "$@\n"; + return $self->next(); + } } } } -- 2.43.2