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

Commit 7190c95

Browse files
committed
- check for array and key
1 parent 8f74d00 commit 7190c95

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/DeepL.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,12 @@ protected function request($url, $body)
431431
$httpCode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
432432
$responseArray = json_decode($response, true);
433433

434-
if ($httpCode != 200) {
434+
if ($httpCode != 200 && is_array($responseArray) && array_key_exists('message', $responseArray)) {
435435
throw new DeepLException($responseArray['message'], $httpCode);
436436
}
437437

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

442442
return $responseArray;

0 commit comments

Comments
 (0)