Skip to content
Snippets Groups Projects
Commit fa4fe406 authored by Robert Lange's avatar Robert Lange
Browse files

refs #19158 [finc] dds mapping in zend-form: fix error handling (e.g. 401)

* also set input division (fakultät) required in dds-form.php
parent 14abd2f3
No related merge requests found
...@@ -105,7 +105,7 @@ return [ ...@@ -105,7 +105,7 @@ return [
'empty_option' => '', 'empty_option' => '',
], ],
'attributes' => [ 'attributes' => [
'required' => false, 'required' => true,
'id' => 'division', 'id' => 'division',
], ],
], ],
......
...@@ -281,15 +281,7 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase ...@@ -281,15 +281,7 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase
->send(); ->send();
if (!$response->isSuccess()) { if (!$response->isSuccess()) {
if ($response->getContent()) { $this->throwErrorMessage($response);
$responseArray = $this->parseJsonAsArray($response->getContent());
if (array_key_exists('error', $responseArray)) {
$message = $responseArray['error'];
}
} else {
$message = 'HTTP status ' . $response->getStatusCode() . ' received';
}
throw new DDSException($message);
} }
$responseArray = $this->parseJsonAsArray($response->getBody()); $responseArray = $this->parseJsonAsArray($response->getBody());
...@@ -585,6 +577,23 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase ...@@ -585,6 +577,23 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase
); );
} }
} }
/**
* @param \Zend\Http\Response $response
* @throws DDSException
*/
protected function throwErrorMessage(\Zend\Http\Response $response): void
{
$message = 'HTTP status ' . $response->getStatusCode() . ' received';
if ($response->getContent()) {
$responseArray = $this->parseJsonAsArray($response->getContent());
if ($responseArray && array_key_exists('error', $responseArray)) {
$message = $responseArray['error'];
}
}
throw new DDSException($message);
}
/** /**
* Retrieve data after successful sending previous record. Beware and keep * Retrieve data after successful sending previous record. Beware and keep
...@@ -962,17 +971,8 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase ...@@ -962,17 +971,8 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase
); );
exit; exit;
} }
$responseArray = $this->parseJsonAsArray($response->getContent());
if ($responseArray !== null && array_key_exists('error', $responseArray)) {
$message = $responseArray['error'];
}
} else {
$message = 'HTTP status ' . $response->getStatusCode() . ' received';
}
if (!empty($message)) {
throw new DDSException($message);
} }
$this->throwErrorMessage($response);
} }
return $this->parseJsonAsArray($response->getBody()); return $this->parseJsonAsArray($response->getBody());
...@@ -1026,15 +1026,7 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase ...@@ -1026,15 +1026,7 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase
->send(); ->send();
if (!$response->isSuccess()) { if (!$response->isSuccess()) {
if ($response->getContent()) { $this->throwErrorMessage($response);
$responseArray = $this->parseJsonAsArray($response->getContent());
if (array_key_exists('error', $responseArray)) {
$message = $responseArray['error'];
}
} else {
$message = 'HTTP status ' . $response->getStatusCode() . ' received';
}
throw new DDSException($message);
} }
$responseArray = $this->parseJsonAsArray($response->getBody()); $responseArray = $this->parseJsonAsArray($response->getBody());
......
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