Skip to content

Commit c1d0ae3

Browse files
committed
shdict:incr(): fixed an error message for bad init arg type to make ngx_lua's tests pass.
1 parent 307596b commit c1d0ae3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/resty/core/shdict.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,12 @@ local function shdict_incr(zone, key, value, init)
341341
local has_init
342342

343343
if init then
344-
if type(init) ~= "number" then
344+
local typ = type(init)
345+
if typ ~= "number" then
345346
init = tonumber(init)
346347

347348
if not init then
348-
return error("init should be a number")
349+
return error("bad init arg: number expected, got " .. typ)
349350
end
350351
end
351352

t/shdict.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ GET /t
995995
--- error_code: 500
996996
--- response_body_like: 500
997997
--- error_log
998-
init should be a number
998+
number expected, got string
999999
--- no_error_log
10001000
[alert]
10011001
[crit]

0 commit comments

Comments
 (0)