Skip to content

Commit 5ecfdde

Browse files
committed
Throw error if a response cant be decoded from API
1 parent 6bb3a81 commit 5ecfdde

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Auspost.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,10 @@ private function closeSocket() {
474474
* @return array associative array
475475
*/
476476
private function convertResponse($data) {
477-
return json_decode($data, true);
477+
$response = json_decode($data, true);
478+
if ($data && is_null($response)) {
479+
throw new \Exception('Could not decode response');
480+
}
481+
return $response;
478482
}
479483
}

0 commit comments

Comments
 (0)