Adding some Error proof on GetAuthority
authorHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Wed, 15 Oct 2008 19:36:44 +0000 (21:36 +0200)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Mon, 24 Nov 2008 17:08:08 +0000 (18:08 +0100)
return undef if there is a problem

Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
C4/AuthoritiesMarc.pm

index deda42a..17857f7 100644 (file)
@@ -679,8 +679,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);