Skip to content

Commit

Permalink
apply suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Apr 28, 2024
1 parent 0526a2f commit 9e8b739
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion kong/clustering/rpc/json_rpc_v2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ local ERROR_MSG = {

function _M.new_error(id, code, msg)
if msg then
msg = assert(tostring(msg))
if type(msg) ~= "string" then
local mt = getmetatable(msg)
-- other types without the metamethod `__tostring` don't
-- generate a meaningful string, we should consider it as a
-- bug since we should not expose something like
-- `"table: 0x7fff0000"` to the RPC caller.
assert(mt.__tostring)
end

msg = tostring(msg)

else
msg = assert(ERROR_MSG[code], "unknown code: " .. tostring(code))
Expand Down

0 comments on commit 9e8b739

Please sign in to comment.