bug_6433: exception handling
Signed-off-by: Magnus Enger <magnus@enger.priv.no>
This commit is contained in:
parent
529842ab6c
commit
5829cef6d8
2 changed files with 21 additions and 8 deletions
|
@ -21,6 +21,7 @@ package C4::Biblio;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use Carp;
|
||||||
|
|
||||||
# use utf8;
|
# use utf8;
|
||||||
use MARC::Record;
|
use MARC::Record;
|
||||||
|
@ -294,6 +295,8 @@ and biblionumber data for indexing.
|
||||||
|
|
||||||
sub ModBiblio {
|
sub ModBiblio {
|
||||||
my ( $record, $biblionumber, $frameworkcode ) = @_;
|
my ( $record, $biblionumber, $frameworkcode ) = @_;
|
||||||
|
croak "No record" unless $record;
|
||||||
|
|
||||||
if ( C4::Context->preference("CataloguingLog") ) {
|
if ( C4::Context->preference("CataloguingLog") ) {
|
||||||
my $newrecord = GetMarcBiblio($biblionumber);
|
my $newrecord = GetMarcBiblio($biblionumber);
|
||||||
logaction( "CATALOGUING", "MODIFY", $biblionumber, "BEFORE=>" . $newrecord->as_formatted );
|
logaction( "CATALOGUING", "MODIFY", $biblionumber, "BEFORE=>" . $newrecord->as_formatted );
|
||||||
|
@ -2667,6 +2670,7 @@ per the bib's MARC framework.
|
||||||
|
|
||||||
sub EmbedItemsInMarcBiblio {
|
sub EmbedItemsInMarcBiblio {
|
||||||
my ($marc, $biblionumber) = @_;
|
my ($marc, $biblionumber) = @_;
|
||||||
|
croak "No MARC record" unless $marc;
|
||||||
|
|
||||||
my $frameworkcode = GetFrameworkCode($biblionumber);
|
my $frameworkcode = GetFrameworkCode($biblionumber);
|
||||||
_strip_item_fields($marc, $frameworkcode);
|
_strip_item_fields($marc, $frameworkcode);
|
||||||
|
|
|
@ -351,8 +351,13 @@ sub export_marc_records_from_sth {
|
||||||
# strung together with no single root element. zebraidx doesn't seem
|
# strung together with no single root element. zebraidx doesn't seem
|
||||||
# to care, though, at least if you're using the GRS-1 filter. It does
|
# to care, though, at least if you're using the GRS-1 filter. It does
|
||||||
# care if you're using the DOM filter, which requires valid XML file(s).
|
# care if you're using the DOM filter, which requires valid XML file(s).
|
||||||
print OUT ($as_xml) ? $marc->as_xml_record(C4::Context->preference('marcflavour')) : $marc->as_usmarc();
|
eval {
|
||||||
$num_exported++;
|
print OUT ($as_xml) ? $marc->as_xml_record(C4::Context->preference('marcflavour')) : $marc->as_usmarc();
|
||||||
|
$num_exported++;
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
warn "Error exporting record $record_number ($record_type) ".($noxml ? "not XML" : "XML");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
|
print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
|
||||||
|
@ -449,15 +454,19 @@ sub get_raw_marc_record {
|
||||||
$fetch_sth->execute($record_number);
|
$fetch_sth->execute($record_number);
|
||||||
if (my ($blob) = $fetch_sth->fetchrow_array) {
|
if (my ($blob) = $fetch_sth->fetchrow_array) {
|
||||||
$marc = MARC::Record->new_from_usmarc($blob);
|
$marc = MARC::Record->new_from_usmarc($blob);
|
||||||
$fetch_sth->finish();
|
unless ($marc) {
|
||||||
} else {
|
warn "error creating MARC::Record from $blob";
|
||||||
return; # failure to find a bib is not a problem -
|
}
|
||||||
# a delete could have been done before
|
|
||||||
# trying to process a record update
|
|
||||||
}
|
}
|
||||||
|
# failure to find a bib is not a problem -
|
||||||
|
# a delete could have been done before
|
||||||
|
# trying to process a record update
|
||||||
|
|
||||||
|
$fetch_sth->finish();
|
||||||
|
return unless $marc;
|
||||||
} else {
|
} else {
|
||||||
eval { $marc = GetMarcBiblio($record_number); };
|
eval { $marc = GetMarcBiblio($record_number); };
|
||||||
if ($@) {
|
if ($@ || !$marc) {
|
||||||
# here we do warn since catching an exception
|
# here we do warn since catching an exception
|
||||||
# means that the bib was found but failed
|
# means that the bib was found but failed
|
||||||
# to be parsed
|
# to be parsed
|
||||||
|
|
Loading…
Reference in a new issue