mirror of
https://github.com/netcccyun/dnsmgr.git
synced 2026-02-21 15:31:12 +08:00
优化错误信息
This commit is contained in:
parent
eb950663e7
commit
496a7d2fd6
@ -357,7 +357,7 @@ function check_proxy($url, $proxy_server, $proxy_port, $type, $proxy_user, $prox
|
||||
throw new Exception('HTTP状态码异常:' . $httpCode);
|
||||
}
|
||||
} catch (GuzzleException $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
throw new Exception(guzzle_error($e));
|
||||
}
|
||||
}
|
||||
|
||||
@ -519,10 +519,26 @@ function http_request($url, $data = null, $referer = null, $cookie = null, $head
|
||||
'body' => $response->getBody()->getContents()
|
||||
];
|
||||
} catch (GuzzleException $e) {
|
||||
throw new Exception('请求失败: ' . $e->getMessage());
|
||||
throw new Exception('请求失败: ' . guzzle_error($e));
|
||||
}
|
||||
}
|
||||
|
||||
function guzzle_error($e)
|
||||
{
|
||||
$errmsg = $e->getMessage();
|
||||
if (preg_match('/^cURL error \d+: /', $errmsg)) {
|
||||
$errmsg = preg_replace('/^cURL error \d+: /', '', $errmsg);
|
||||
}
|
||||
$pos = strpos($errmsg, ' (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)');
|
||||
if ($pos !== false) {
|
||||
$errmsg = substr($errmsg, 0, $pos);
|
||||
}
|
||||
if (strlen($errmsg) > 100) {
|
||||
$errmsg = substr($errmsg, 0, 97) . '...';
|
||||
}
|
||||
return $errmsg;
|
||||
}
|
||||
|
||||
function curl_set_proxy(&$ch)
|
||||
{
|
||||
$proxy_server = config_get('proxy_server');
|
||||
|
||||
@ -82,11 +82,7 @@ class CheckUtils
|
||||
}
|
||||
} catch (GuzzleException $e) {
|
||||
$status = false;
|
||||
$errmsg = $e->getMessage();
|
||||
if (preg_match('/^cURL error \d+: /', $errmsg)) {
|
||||
$errmsg = preg_replace('/^cURL error \d+: /', '', $errmsg);
|
||||
}
|
||||
$errmsg = str_replace(' (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)', '', $errmsg);
|
||||
$errmsg = guzzle_error($e);
|
||||
if (strlen($errmsg) > 100) {
|
||||
$errmsg = substr($errmsg, 0, 97) . '...';
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user