Skip to content

Commit

Permalink
新增错误信息
Browse files Browse the repository at this point in the history
  • Loading branch information
a67793581 committed Feb 19, 2021
1 parent ec519d8 commit 37703cf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"minimum-stability": "stable",
"require": {
"ext-curl": "*",
"php": ">=5.4"
"php": ">=5.4",
"ext-json": "*"
},
"require-dev": {
"ext-curl": "*",
Expand Down
6 changes: 3 additions & 3 deletions src/Clients/DingTalkClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,14 @@ public function send(array $data)
}
$res = $this->httpPostJson($url, $jsonStr);
if ($res['httpCode'] != 200) {
throw new RobotWebHookException($res['body'], $res['httpCode']);
throw new RobotWebHookException(json_encode($res), 100002);
}
$body = json_decode($res['body'], true);
if ($body['errcode']) {
throw new RobotWebHookException($res['body'], $res['httpCode']);
throw new RobotWebHookException(json_encode($res), 100003);
}
return $res;
}


}
}
4 changes: 2 additions & 2 deletions src/Clients/EnterpriseWeChatClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ public function send(array $data)
}
$res = $this->httpPostJson($this->config['web_hook_url'], json_encode($data));
if ($res['httpCode'] != 200) {
throw new RobotWebHookException($res['body'], $res['httpCode']);
throw new RobotWebHookException(json_encode($res), 100002);
}
return $res;
}
}
}
5 changes: 3 additions & 2 deletions src/Traits/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ function httpPostJson($url, $jsonStr)
);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
return array('url' => $url, 'jsonStr' => $jsonStr, 'httpCode' => $httpCode, 'body' => $response);
return array('url' => $url, 'jsonStr' => $jsonStr, 'httpCode' => $httpCode, 'body' => $response, 'error' => $error);
}
}
}

0 comments on commit 37703cf

Please sign in to comment.