using pcall to catch exception

This commit is contained in:
2022-06-26 18:27:00 +08:00
parent 701eb48609
commit ec5394ac56
+2 -2
View File
@@ -22,7 +22,7 @@ local function get_access_token()
ngx.log(ngx.INFO, "START REQUEST TO GET ACCESS TOKEN -> ", pl.write(sudoerToken))
local req_status, resp, resp_err = pcall(httpc:request_uri,
local no_exception, resp, resp_err = pcall(httpc:request_uri,
remote_url,
{
ssl_verify = false, -- 设置参数 ssl_verify 为false 不校验ssl证书
@@ -35,7 +35,7 @@ local function get_access_token()
ngx.log(ngx.INFO, "RESP -> ", pl.write(resp))
if req_status == true then
if no_exception == true then
if 200 ~= resp.status then
ngx.log(ngx.ERR, "GET ACCESS TOKEN *FAILED*", pl.write(resp_err))
ngx.say(pl.write(resp_err))