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

Smarter error handling.

parent 77c1ba4b
No related merge requests found
...@@ -270,7 +270,7 @@ class Backend extends AbstractBackend ...@@ -270,7 +270,7 @@ class Backend extends AbstractBackend
try { try {
$authenticationToken = $this->getAuthenticationToken(); $authenticationToken = $this->getAuthenticationToken();
// check to see if the profile is overriden // check to see if the profile is overriden
$overrideProfile = $params->get('profile'); $overrideProfile = (null !== $params) ? $params->get('profile') : null;
if (isset($overrideProfile)) { if (isset($overrideProfile)) {
$this->profile = $overrideProfile; $this->profile = $overrideProfile;
} }
...@@ -288,16 +288,26 @@ class Backend extends AbstractBackend ...@@ -288,16 +288,26 @@ class Backend extends AbstractBackend
$an, $dbId, $authenticationToken, $sessionToken, $hlTerms $an, $dbId, $authenticationToken, $sessionToken, $hlTerms
); );
} catch (\EbscoEdsApiException $e) { } catch (\EbscoEdsApiException $e) {
if ($e->getApiErrorCode() == 104) { // if the auth or session token was invalid, try once more
switch ($e->getApiErrorCode()) {
case 104:
case 108:
case 109:
try { try {
$authenticationToken = $this->getAuthenticationToken(true); // For error 104, retry auth token; for 108/9, retry sess token:
if ($e->getApiErrorCode() == 104) {
$authenticationToken = $this->getAuthenticationToken(true);
} else {
$sessionToken = $this->getSessionToken(true);
}
$response = $this->client->retrieve( $response = $this->client->retrieve(
$an, $dbId, $authenticationToken, $sessionToken, $hlTerms $an, $dbId, $authenticationToken, $sessionToken, $hlTerms
); );
} catch(Exception $e) { } catch(Exception $e) {
throw new BackendException($e->getMessage(), $e->getCode(), $e); throw new BackendException($e->getMessage(), $e->getCode(), $e);
} }
} else { break;
default:
throw $e; 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