mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-24 13:40:29 +01:00
Sendcloud error handling
This commit is contained in:
parent
3fe2c7a5d9
commit
575ab86157
@ -77,9 +77,9 @@ class SendCloudApi
|
||||
$response = $this->sendRequest($uri, null, true, ['parcel' => $parcel->toApiRequest()], [200,400]);
|
||||
switch ($response['code']) {
|
||||
case 200:
|
||||
if (isset($response->parcel))
|
||||
if (isset($response['body']->parcel))
|
||||
try {
|
||||
return ParcelResponse::fromApiResponse($response->parcel);
|
||||
return ParcelResponse::fromApiResponse($response['body']->parcel);
|
||||
} catch (Exception $e) {
|
||||
throw new SendcloudApiException(previous: $e);
|
||||
}
|
||||
|
@ -8,11 +8,11 @@ class SendcloudApiException extends Exception
|
||||
{
|
||||
public static function fromResponse(array $response) : SendcloudApiException {
|
||||
if (!isset($response['body']) || !is_object($response['body']))
|
||||
return new SendcloudApiException();
|
||||
return new SendcloudApiException(print_r($response,true));
|
||||
|
||||
return new SendcloudApiException(
|
||||
$response['body']->error->message ?? '',
|
||||
$response['body']->error->code ?? 0
|
||||
print_r($response['body'],true),
|
||||
$response['code']
|
||||
);
|
||||
}
|
||||
}
|
@ -353,7 +353,7 @@ abstract class Versanddienstleister
|
||||
public function Paketmarke(string $target, string $docType, int $docId): void
|
||||
{
|
||||
$address = $this->GetAdressdaten($docId, $docType);
|
||||
if (isset($_SERVER['HTTP_CONTENT_TYPE']) && ($_SERVER['HTTP_CONTENT_TYPE'] === 'application/json')) {
|
||||
if (isset($_SERVER['CONTENT_TYPE']) && ($_SERVER['CONTENT_TYPE'] === 'application/json')) {
|
||||
$json = json_decode(file_get_contents('php://input'));
|
||||
$ret = [];
|
||||
if ($json->submit == 'print') {
|
||||
|
@ -131,7 +131,7 @@ class Versandart_sendcloud extends Versanddienstleister
|
||||
$ret->Errors[] = $result;
|
||||
}
|
||||
} catch (SendcloudApiException $e) {
|
||||
$ret->Errors[] = $e->getMessage();
|
||||
$ret->Errors[] = strval($e);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user