-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: callback handle error with non-strings
- Loading branch information
Showing
2 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
return require('lib/tap')(function (test) | ||
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 = assert(msg) | ||
return o | ||
end | ||
|
||
function Error:__tostring() | ||
return assert(tostring(self.msg)) | ||
end | ||
|
||
local timer = uv.new_timer() | ||
timer:start(10, 0, function() | ||
timer:stop() | ||
timer:close() | ||
local e = Error.new('Error in timeout callback') | ||
error(e) | ||
end) | ||
end) | ||
end) |