Skip to content
Snippets Groups Projects
Commit 2ae5b8cd authored by Demian Katz's avatar Demian Katz
Browse files

Further refinement of exception handling.

parent 86acbd31
No related merge requests found
......@@ -34,8 +34,9 @@ use InvalidArgumentException;
use VuFindSearch\Backend\Exception\BackendException;
use VuFindSearch\Backend\Exception\HttpErrorException;
use VuFindSearch\Backend\Exception\RemoteErrorException;
use VuFindSearch\Backend\Exception\RequestErrorException;
use VuFindSearch\Backend\Solr\Document\AbstractDocument;
use VuFindSearch\ParamBag;
......@@ -377,6 +378,24 @@ class Connector implements \Zend\Log\LoggerAwareInterface
|| $ex instanceof RequestErrorException;
}
/**
* If an unexpected exception type was received, wrap it in a generic
* BackendException to standardize upstream handling.
*
* @param \Exception $ex Exception
*/
protected function forceToBackendException($ex)
{
// Don't wrap specific backend exceptions....
if ($ex instanceof RemoteErrorException
|| $ex instanceof RequestErrorException
|| $ex instanceof HttpErrorException
) {
return $ex;
}
return new BackendException('Problem connecting to Solr.', null, $ex);
}
/**
* Try all Solr URLs until we find one that works (or throw an exception).
*
......@@ -405,7 +424,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface
return $this->send($client);
} catch (\Exception $ex) {
if ($this->isRethrowableSolrException($ex)) {
throw $ex;
throw $this->forceToBackendException($ex);
}
$exception = $ex;
}
......@@ -413,7 +432,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface
// If we got this far, everything failed -- throw a BackendException with
// the most recent exception caught above set as the previous exception.
throw new BackendException('Problem connecting to Solr.', null, $exception);
throw $this->forceToBackendException($exception);
}
/**
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment