Skip to content

Commit cddd9c5

Browse files
willpower232adamcooke
authored andcommitted
do not presume the existence of a code when throwing an error
1 parent 25e7fde commit cddd9c5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/Client.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ public function makeRequest($controller, $action, $parameters)
3232
if ($json->status == 'success') {
3333
return $json->data;
3434
} else {
35-
throw new Error(sprintf('[%s] %s', $json->data->code, $json->data->message));
35+
if (isset($json->data->code)) {
36+
throw new Error(sprintf('[%s] %s', $json->data->code, $json->data->message));
37+
} else {
38+
throw new Error($json->data->message);
39+
}
3640
}
3741
}
3842

0 commit comments

Comments
 (0)