throw array 2 json

This commit is contained in:
dongwei 2019-01-17 15:58:12 +08:00
parent fd82951c4a
commit b0ffeb7bad

View File

@ -125,7 +125,8 @@ class Client
try { try {
$body = \GuzzleHttp\json_decode($resp->getBody(), true); $body = \GuzzleHttp\json_decode($resp->getBody(), true);
if (isset($body['error']) && isset($body['error']['code']) && isset($body['error']['message'])) { if (isset($body['error']) && isset($body['error']['code']) && isset($body['error']['message'])) {
throw new RpcServerException($body['error']['message'], $body['error']['code']); $message = is_array($body['error']['message']) ? json_encode($body['error']['message']) : $body['error']['message'];
throw new RpcServerException($message, $body['error']['code']);
} }
return $body['result']; return $body['result'];