bugfix: catch ZOOM exceptions in simple Search.pm
Now warns and returns error value, instead of aborting the calling CGI. Signed-off-by: Chris Cormack <crc@liblime.com> Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
parent
121a067dd1
commit
c8a9dfa398
1 changed files with 24 additions and 12 deletions
36
C4/Search.pm
36
C4/Search.pm
|
@ -217,19 +217,31 @@ sub SimpleSearch {
|
|||
|
||||
# Connect & Search
|
||||
for ( my $i = 0 ; $i < @servers ; $i++ ) {
|
||||
$zconns[$i] = C4::Context->Zconn( $servers[$i], 1 );
|
||||
$tmpresults[$i] =
|
||||
$zconns[$i]
|
||||
->search( new ZOOM::Query::CCL2RPN( $query, $zconns[$i] ) );
|
||||
eval {
|
||||
$zconns[$i] = C4::Context->Zconn( $servers[$i], 1 );
|
||||
$tmpresults[$i] =
|
||||
$zconns[$i]
|
||||
->search( new ZOOM::Query::CCL2RPN( $query, $zconns[$i] ) );
|
||||
|
||||
# getting error message if one occured.
|
||||
my $error =
|
||||
$zconns[$i]->errmsg() . " ("
|
||||
. $zconns[$i]->errcode() . ") "
|
||||
. $zconns[$i]->addinfo() . " "
|
||||
. $zconns[$i]->diagset();
|
||||
|
||||
# getting error message if one occured.
|
||||
my $error =
|
||||
$zconns[$i]->errmsg() . " ("
|
||||
. $zconns[$i]->errcode() . ") "
|
||||
. $zconns[$i]->addinfo() . " "
|
||||
. $zconns[$i]->diagset();
|
||||
|
||||
return ( $error, undef ) if $zconns[$i]->errcode();
|
||||
return ( $error, undef ) if $zconns[$i]->errcode();
|
||||
};
|
||||
if ($@) {
|
||||
# caught a ZOOM::Exception
|
||||
my $error =
|
||||
$@->message() . " ("
|
||||
. $@->code() . ") "
|
||||
. $@->addinfo() . " "
|
||||
. $@->diagset();
|
||||
warn $error;
|
||||
return ( $error, undef );
|
||||
}
|
||||
}
|
||||
my $hits;
|
||||
my $ev;
|
||||
|
|
Loading…
Reference in a new issue