mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Try improve error reporting
This commit is contained in:
parent
3b22f6ccf9
commit
58a31a1b32
16 changed files with 164 additions and 55 deletions
|
|
@ -1,4 +1,3 @@
|
|||
local throw = require "./throw"
|
||||
local graph = require "./graph"
|
||||
type Node<T> = graph.Node<T>
|
||||
local create_node = graph.create_node
|
||||
|
|
@ -14,21 +13,20 @@ local function root<T...>(fn: (destroy: () -> ()) -> T...): (() -> (), T...)
|
|||
refs[node] = true -- prevent gc of root node
|
||||
|
||||
local destroy = function()
|
||||
if not refs[node] then throw "root already destroyed" end
|
||||
if not refs[node] then error "root already destroyed" end
|
||||
refs[node] = nil
|
||||
destroy(node)
|
||||
end
|
||||
|
||||
push_scope(node)
|
||||
|
||||
local function efn(err: string) return debug.traceback(err, 3) end
|
||||
local result = { xpcall(fn, efn, destroy) }
|
||||
local result = { xpcall(fn, debug.traceback, destroy) }
|
||||
|
||||
pop_scope()
|
||||
|
||||
if not result[1] then
|
||||
destroy()
|
||||
throw(`error while running root():\n\n{result[2]}`)
|
||||
error(`error while running root():\n\n{result[2]}`, 0)
|
||||
end
|
||||
|
||||
return destroy, unpack(result :: any, 2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue