Commit 136a7412 authored by 杨培's avatar 杨培

修复接口调用错误

接口报错时显示详细的接口
parent 2008066c
...@@ -109,10 +109,10 @@ class Client ...@@ -109,10 +109,10 @@ class Client
list($httpCode, $response) = $instance->request($url, $params); list($httpCode, $response) = $instance->request($url, $params);
if ($httpCode == 200 && $response) { if ($httpCode == 200 && $response !== false) {
$data = @json_decode($response, true); $data = @json_decode($response, true);
if (json_last_error() !== JSON_ERROR_NONE) { if (json_last_error() !== JSON_ERROR_NONE) {
throw new ClientException('接口返回数据异常: ' . $response); throw new ClientException("接口 $api 返回数据异常: " . $response);
} }
return $data; return $data;
} }
...@@ -128,11 +128,11 @@ class Client ...@@ -128,11 +128,11 @@ class Client
throw new ApiException("{$e['class']}: {$e['message']}", $e['code']); throw new ApiException("{$e['class']}: {$e['message']}", $e['code']);
} }
if ($httpCode === 0) { if ($httpCode == 0) {
throw new ClientException('接口请求异常: '.$response, $httpCode); throw new ClientException("接口 $api 请求异常: ".$response);
} else {
throw new ClientException("接口 $api 响应异常: ".$response, $httpCode);
} }
throw new ClientException('接口响应异常: '.$response, $httpCode);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment