From c8a9dfa398b86faae2896fca4a01084c59350372 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 6 Dec 2007 18:07:39 -0600 Subject: [PATCH] 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 Signed-off-by: Joshua Ferraro --- C4/Search.pm | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index c42ca1d84f..ab0d4070c9 100644 --- a/C4/Search.pm +++ b/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] ) ); - - # getting error message if one occured. - my $error = - $zconns[$i]->errmsg() . " (" - . $zconns[$i]->errcode() . ") " - . $zconns[$i]->addinfo() . " " - . $zconns[$i]->diagset(); + 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(); - 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; -- 2.39.5