Skip to content
Snippets Groups Projects
Commit ce6fdef6 authored by Demian Katz's avatar Demian Katz Committed by Robert Lange
Browse files

Swallow backend exceptions when tolerating missing records.

parent 8f376336
No related merge requests found
......@@ -32,6 +32,7 @@ namespace VuFind\Record;
use VuFind\Exception\RecordMissing as RecordMissingException;
use VuFind\Record\FallbackLoader\PluginManager as FallbackLoader;
use VuFind\RecordDriver\PluginManager as RecordFactory;
use VuFindSearch\Backend\Exception\BackendException;
use VuFindSearch\ParamBag;
use VuFindSearch\Service as SearchService;
......@@ -118,8 +119,14 @@ class Loader implements \Zend\Log\LoggerAwareInterface
$results = $this->recordCache->lookup($id, $source);
}
if (empty($results)) {
$results = $this->searchService->retrieve($source, $id, $params)
->getRecords();
try {
$results = $this->searchService->retrieve($source, $id, $params)
->getRecords();
} catch (BackendException $e) {
if (!$tolerateMissing) {
throw $e;
}
}
}
if (empty($results) && null !== $this->recordCache
&& $this->recordCache->isFallback($source)
......@@ -134,8 +141,15 @@ class Loader implements \Zend\Log\LoggerAwareInterface
if ($this->fallbackLoader
&& $this->fallbackLoader->has($source)
) {
$fallbackRecords = $this->fallbackLoader->get($source)
->load([$id]);
try {
$fallbackRecords = $this->fallbackLoader->get($source)
->load([$id]);
} catch (BackendException $e) {
if (!$tolerateMissing) {
throw $e;
}
$fallbackRecords = [];
}
if (count($fallbackRecords) == 1) {
return $fallbackRecords[0];
......@@ -188,7 +202,7 @@ class Loader implements \Zend\Log\LoggerAwareInterface
$genuineRecords = $this->searchService
->retrieveBatch($source, $list->getUnchecked(), $params)
->getRecords();
} catch (\VuFindSearch\Backend\Exception\BackendException $e) {
} catch (BackendException $e) {
if (!$tolerateBackendExceptions) {
throw $e;
}
......@@ -210,7 +224,7 @@ class Loader implements \Zend\Log\LoggerAwareInterface
try {
$fallbackRecords = $this->fallbackLoader->get($source)
->load($list->getUnchecked());
} catch (\VuFindSearch\Backend\Exception\BackendException $e) {
} catch (BackendException $e) {
if (!$tolerateBackendExceptions) {
throw $e;
}
......
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