Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
- check for array and key
Browse files Browse the repository at this point in the history
  • Loading branch information
VimS committed Aug 19, 2020
1 parent 8f74d00 commit 7190c95
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/DeepL.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,12 @@ protected function request($url, $body)
$httpCode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
$responseArray = json_decode($response, true);

if ($httpCode != 200) {
if ($httpCode != 200 && is_array($responseArray) && array_key_exists('message', $responseArray)) {
throw new DeepLException($responseArray['message'], $httpCode);
}

if (false === is_array($responseArray)) {
throw new DeepLException('The Response seems to not be valid JSON.');
throw new DeepLException('The Response seems to not be valid JSON.', $httpCode);
}

return $responseArray;
Expand Down

0 comments on commit 7190c95

Please sign in to comment.