Skip to content

Commit

Permalink
chore: update time callback error non-strings
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaozg committed Aug 19, 2023
1 parent e3c93a6 commit a37af33
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions tests/test-timer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,27 @@ return require('lib/tap')(function (test)
assert(huge_timer:get_due_in()==0xffff)
end, "1.40.0")

test("timer init", function(print, p, expect, uv)
test("timer callback with errors", function(print, p, expect, uv)
local Error = {}
Error.__index = Error

function Error.new(msg)
local o = setmetatable({}, Error)
o.msg = msg
return o
end

function Error:__tostring()
return self.msg
end

local timer = uv.new_timer()
timer:start(10, 0, function()
timer:stop()
timer:close()
error('Error in timeout callback')
local e = Error.new('Error in timeout callback')
print('e:', e)
error(e)
end)
end)
end)

0 comments on commit a37af33

Please sign in to comment.