Adding some Error proof on GetAuthority

return undef if there is a problem

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
This commit is contained in:
Henri-Damien LAURENT 2008-11-19 14:58:20 +01:00 committed by Galen Charlton
parent e7282020f7
commit e5d1bced25
1 changed files with 3 additions and 2 deletions

View File

@ -711,8 +711,9 @@ sub GetAuthority {
my $sth=$dbh->prepare("select authtypecode, marcxml from auth_header where authid=?");
$sth->execute($authid);
my ($authtypecode, $marcxml) = $sth->fetchrow;
my $record=MARC::Record->new_from_xml(StripNonXmlChars($marcxml),'UTF-8',
(C4::Context->preference("marcflavour") eq "UNIMARC"?"UNIMARCAUTH":C4::Context->preference("marcflavour")));
my $record=eval {MARC::Record->new_from_xml(StripNonXmlChars($marcxml),'UTF-8',
(C4::Context->preference("marcflavour") eq "UNIMARC"?"UNIMARCAUTH":C4::Context->preference("marcflavour")))};
return undef if ($@);
$record->encoding('UTF-8');
if (C4::Context->preference("marcflavour") eq "MARC21") {
my ($auth_type_tag, $auth_type_subfield) = get_auth_type_location($authtypecode);