Skip to content

Commit

Permalink
优化访问后端接口出现错误时的错误消息
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-smile committed Aug 10, 2023
1 parent 08e7946 commit 2f889a1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/apisix/plugins/bk-components/bkauth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ function _M.verify_app_secret(app_code, app_secret)
)

if not (res and res.body) then
core.log.error(string_format("failed to request %s, err: %s, response: nil", url, err))
return nil, string_format("failed to request third-party api, url: %s, err: %s, response: nil", url, err)
err = string_format("failed to request third-party api, url: %s, err: %s, response: nil", url, err)
core.log.error(err)
return nil, err
end

-- 响应格式正常,错误码 404,表示应用不存在
Expand Down Expand Up @@ -126,8 +127,9 @@ function _M.list_app_secrets(app_code)
)

if not (res and res.body) then
core.log.error(string_format("failed to request %s, err: %s, response: nil", url, err))
return nil, string_format("failed to request third-party api, url: %s, err: %s, response: nil", url, err)
err = string_format("failed to request third-party api, url: %s, err: %s, response: nil", url, err)
core.log.error(err)
return nil, err
end

-- 响应格式正常,错误码 404,表示应用不存在
Expand Down Expand Up @@ -195,8 +197,9 @@ function _M.verify_access_token(access_token)
)

if not (res and res.body) then
core.log.error(string_format("failed to request %s, err: %s, response: nil", url, err))
return nil, string_format("failed to request third-party api, url: %s, err: %s, response: nil", url, err)
err = string_format("failed to request third-party api, url: %s, err: %s, response: nil", url, err)
core.log.error(err)
return nil, err
end

local result = core.json.decode(res.body)
Expand Down

0 comments on commit 2f889a1

Please sign in to comment.