From: Jason Stephenson Date: Sun, 7 Aug 2016 14:23:42 +0000 (-0400) Subject: Perl eval improvements in eg_staged_bib_overlay. X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=commitdiff_plain;h=e646ed5624e97e917dff2b8fc11a3bfbaf3175e3 Perl eval improvements in eg_staged_bib_overlay. Two changes to improve the eval conditions added in the previous commit: 1. Both error handlers now warn with the same message: Record $i is bad: $@; skipping. Thereby reporting the original message in case the user wants to try and recover the records later. 2. If a bib record's 901$c is either missing or not numeric, die() is called with a message to that effect. This eliminates the Perl warnings about exiting an eval block with next. Signed-off-by: Jason Stephenson Signed-off-by: Galen Charlton --- diff --git a/eg_staged_bib_overlay b/eg_staged_bib_overlay index a517a6a..836795b 100755 --- a/eg_staged_bib_overlay +++ b/eg_staged_bib_overlay @@ -285,14 +285,13 @@ sub handle_stage_bibs { my $marc = MARC::Record->new_from_usmarc($_); my $bibid = $marc->subfield('901', 'c'); if ($bibid !~ /^\d+$/) { - print STDERR "Record $i is suspect; skipping\n"; - next; + die('Subfield 901$c is not numeric or missing.'); } my $xml = OpenILS::Application::AppUtils->entityize($marc->as_xml_record()); $ins->execute($xml, $bibid); }; if ($@) { - print STDERR "Record $i is bad; skipping\n"; + warn("Record $i is bad: $@; skipping."); next; } } @@ -473,7 +472,7 @@ sub handle_stage_auths { $ins->execute($xml, $authid, $lccn, $cancelled_lccn, $xml); }; if ($@) { - print STDERR "Record $i is bad; skipping\n"; + warn("Record $i is bad: $@; skipping."); next; } }