diff --git a/src/graph.luau b/src/graph.luau index b85b66e..96e95fe 100644 --- a/src/graph.luau +++ b/src/graph.luau @@ -21,10 +21,11 @@ export type Node = { local scopes = { n = 0 } :: { [number]: Node, n: number } -- scopes stack -local function efn(err: string) - local trace = debug.traceback(err, 2) +local function efn(err: unknown) + local message = tostring(err) + local trace = debug.traceback(message, 2) - if string.find(err, "^effect error stacktrace") then -- if effect error is nested + if string.find(message, "^effect error stacktrace") then -- if effect error is nested trace = string.gsub(" " .. trace, "\n", function() -- indent entire error return "\n " end) diff --git a/test/tests.luau b/test/tests.luau index cd9cd1d..3042917 100644 --- a/test/tests.luau +++ b/test/tests.luau @@ -3047,6 +3047,15 @@ TEST("strict", wrap_root(function() CHECK(not ok) end + do CASE "error with a non-string value" + local ok, err = pcall(effect, function() + error({}) + end) + + CHECK(not ok) + CHECK(string.find(err, "table: ")) + end + do CASE "duplicate properties" local ok = pcall(function() create "TextLabel" {