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:
Galen Charlton 2007-12-06 18:07:39 -06:00 committed by Joshua Ferraro
parent 121a067dd1
commit c8a9dfa398

View file

@ -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;