From 6f8216512853b3d705bea46b3e362fc83d996bb1 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Tue, 22 Dec 2015 09:11:55 -0500 Subject: [PATCH] LP#1528596: Add another eval/warning check in marc_export. This one checks if the $marc->insert_grouped_field for adding items throws an error or warning. This happened on my records with a bad field that somehow made it through the conversion from XML. Signed-off-by: Jason Stephenson Signed-off-by: Ben Shum --- Open-ILS/src/support-scripts/marc_export.in | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/support-scripts/marc_export.in b/Open-ILS/src/support-scripts/marc_export.in index f894e57725..6e0faceabd 100755 --- a/Open-ILS/src/support-scripts/marc_export.in +++ b/Open-ILS/src/support-scripts/marc_export.in @@ -470,7 +470,13 @@ sub next { next unless ($acp); my $location = $Marque::config->option_value('location'); my $price = ($acp->price() ? $Marque::config->option_value('money').$acp->price() : ''); - $marc->insert_grouped_field( + eval { + local $SIG{__WARN__} = sub { + my $message = "Warning from bibliographic record " . $r->id() . ": " + . shift; + warn($message); + }; + $marc->insert_grouped_field( MARC::Field->new( '852', '4', ' ', ($location ? ('a' => $location) : ()), @@ -487,6 +493,12 @@ sub next { (!$U->is_true($acp->circulate()) ? (x => 'noncirculating') : ()), (!$U->is_true($acp->opac_visible()) ? (x => 'hidden') : ()) )); + }; + if ($@) { + warn("Error in bibliographic record " . $r->id() . ": $@"); + import MARC::File::XML; # Reset SAX Parser. + return $self->next(); + } } } if ($Marque::config->option_value('mfhd')) { -- 2.43.2