diff --git a/module/VuFind/src/VuFind/ILS/Driver/Alma.php b/module/VuFind/src/VuFind/ILS/Driver/Alma.php index 8de446df5eec254f788c8ee827f37569e3835aea..538f66271d748a146d7dfc2090e89bd8363c3f28 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Alma.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Alma.php @@ -181,7 +181,7 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface // Execute HTTP call $result = $client->send(); } catch (\Exception $e) { - $this->logError("$method request for $url failed: " . $e->getMessage()); + $this->logError("$method request '$url' failed: " . $e->getMessage()); throw new ILSException($e->getMessage()); } @@ -194,14 +194,14 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface $urlParams = $client->getRequest()->getQuery()->toString(); $fullUrl = $url . (strpos($url, '?') === false ? '?' : '&') . $urlParams; $this->debug( - "[$duration] $method request for $fullUrl results ($statusCode):\n" + "[$duration] $method request '$fullUrl' results ($statusCode):\n" . $answer ); // Check for error if ($result->isServerError()) { $this->logError( - "$method request for $url failed, HTTP error code: $statusCode" + "$method request '$url' failed, HTTP error code: $statusCode" ); throw new ILSException('HTTP error code: ' . $statusCode, $statusCode); } @@ -210,7 +210,7 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface $xml = simplexml_load_string($answer); } catch (\Exception $e) { $this->logError( - "Could not parse response for $method request for $url: " + "Could not parse response for $method request '$url': " . $e->getMessage() . ". Response was:\n" . $result->getHeaders()->toString() . "\n\n$answer" @@ -228,18 +228,14 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface } else { $almaErrorMsg = $xml->errorList->error[0]->errorMessage ?? '[could not parse error message]'; - error_log( - '[ALMA] ' . $almaErrorMsg . ' | Call to: ' . $client->getUri() . - '. GET params: ' . var_export($paramsGet, true) . '. POST params: ' . - var_export($paramsPost, true) . '. Result body: ' . - $result->getBody() . '. HTTP status code: ' . $statusCode - ); - throw new ILSException( - "Alma error message for $method request for $url: " - . $almaErrorMsg . ' | HTTP error code: ' - . $statusCode, - $statusCode + $errorMsg = "Alma error for $method request '$url' (status code" + . " $statusCode): $almaErrorMsg"; + $this->logError( + $errorMsg . '. GET params: ' . var_export($paramsGet, true) + . '. POST params: ' . var_export($paramsPost, true) + . '. Result body: ' . $result->getBody() ); + throw new ILSException($errorMsg, $statusCode); } return $returnStatus ? [$returnValue, $statusCode] : $returnValue; @@ -564,9 +560,9 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface new \DateInterval($newUserConfig['expiryDate']) ); } catch (\Exception $exception) { - $errorMessage = 'Configuration "expiryDate" in Alma.ini (see ' . + $errorMessage = 'Configuration "expiryDate" in Alma ini (see ' . '[NewUser] section) has the wrong format!'; - error_log('[ALMA]: ' . $errorMessage); + $this->logError($errorMessage); throw new \VuFind\Exception\Auth($errorMessage); } } else { @@ -586,9 +582,9 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface new \DateInterval($newUserConfig['purgeDate']) ); } catch (\Exception $exception) { - $errorMessage = 'Configuration "purgeDate" in Alma.ini (see ' . + $errorMessage = 'Configuration "purgeDate" in Alma ini (see ' . '[NewUser] section) has the wrong format!'; - error_log('[ALMA]: ' . $errorMessage); + $this->logError($errorMessage); throw new \VuFind\Exception\Auth($errorMessage); } } @@ -1474,8 +1470,12 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface if ($response->isSuccess()) { return ['success' => true]; } else { - // TODO: Throw an error - error_log($response->getBody()); + $url = $client->getRequest()->getUriString(); + $statusCode = $response->getStatusCode(); + $this->logError( + "Alma error for hold POST request '$url' (status code $statusCode): " + . $response->getBody() + ); } // Get error message