using pcall to catch exception
This commit is contained in:
@@ -22,7 +22,7 @@ local function get_access_token()
|
|||||||
|
|
||||||
ngx.log(ngx.INFO, "START REQUEST TO GET ACCESS TOKEN -> ", pl.write(sudoerToken))
|
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,
|
remote_url,
|
||||||
{
|
{
|
||||||
ssl_verify = false, -- 设置参数 ssl_verify 为false 不校验ssl证书
|
ssl_verify = false, -- 设置参数 ssl_verify 为false 不校验ssl证书
|
||||||
@@ -35,7 +35,7 @@ local function get_access_token()
|
|||||||
|
|
||||||
ngx.log(ngx.INFO, "RESP -> ", pl.write(resp))
|
ngx.log(ngx.INFO, "RESP -> ", pl.write(resp))
|
||||||
|
|
||||||
if req_status == true then
|
if no_exception == true then
|
||||||
if 200 ~= resp.status then
|
if 200 ~= resp.status then
|
||||||
ngx.log(ngx.ERR, "GET ACCESS TOKEN *FAILED*", pl.write(resp_err))
|
ngx.log(ngx.ERR, "GET ACCESS TOKEN *FAILED*", pl.write(resp_err))
|
||||||
ngx.say(pl.write(resp_err))
|
ngx.say(pl.write(resp_err))
|
||||||
|
|||||||
Reference in New Issue
Block a user