Try improve error reporting

This commit is contained in:
aaron 2024-12-27 22:43:01 +00:00
parent 3b22f6ccf9
commit 58a31a1b32
16 changed files with 164 additions and 55 deletions

View file

@ -1,6 +1,5 @@
local typeof = game and typeof or require "../test/mock".typeof :: never
local throw = require "./throw"
local graph = require "./graph"
local get_scope = graph.get_scope
local push_cleanup = graph.push_cleanup
@ -14,14 +13,14 @@ local function helper(obj: any)
elseif obj.disconnect then function() obj:disconnect() end
elseif obj.Destroy then function() obj:Destroy() end
elseif obj.Disconnect then function() obj:Disconnect() end
else throw("cannot cleanup given object")
else error "cannot cleanup given object"
end
local function cleanup(value: unknown)
local scope = get_scope()
if not scope then
throw "cannot cleanup outside a stable or reactive scope"
error "cannot cleanup outside a stable or reactive scope"
end; assert(scope)
if type(value) == "function" then