Skip to content

Commit

Permalink
Update OpenProvider error handling, return api response data in provi…
Browse files Browse the repository at this point in the history
…sion result data
  • Loading branch information
uphlewis committed Sep 25, 2024
1 parent cf6c76d commit e0de9d8
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/OpenProvider/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,13 +649,13 @@ protected function _callApi(array $params, string $path, string $method = 'GET',
protected function _handleApiErrorResponse(Response $response, $responseData): void
{
$errorData = [
'http_code' => $response->getStatusCode()
'http_code' => $response->getStatusCode(),
'response_data' => $responseData,
];

if (!isset($responseData['code'])) {
throw $this->errorResult('Unexpected provider response', $errorData, [
'response_body' => $response->getBody()->__toString(),
]);
$errorData['response_body'] = $response->getBody()->__toString();
$this->errorResult('Unexpected provider response', $errorData);
}

$message = 'Provider Error: ';
Expand All @@ -676,9 +676,7 @@ protected function _handleApiErrorResponse(Response $response, $responseData): v
$message .= ($responseData['desc'] ?? 'Unknown error');
}

throw $this->errorResult($message, $errorData, [
'response_data' => $responseData,
]);
$this->errorResult($message, $errorData);
}

protected function _getToken(): string
Expand Down

0 comments on commit e0de9d8

Please sign in to comment.