mirror of
https://github.com/centau/vide.git
synced 2026-10-20 17:34:08 +00:00
Include stack trace in effect errors
This commit is contained in:
parent
f3bfc65607
commit
4b467a9b30
1 changed files with 10 additions and 3 deletions
|
|
@ -31,7 +31,14 @@ local function efn(err: string)
|
||||||
end
|
end
|
||||||
|
|
||||||
trace ..= "\nsource update stacktrace:"
|
trace ..= "\nsource update stacktrace:"
|
||||||
return trace
|
return trace
|
||||||
|
end
|
||||||
|
|
||||||
|
local function effect_traceback(err: unknown): string
|
||||||
|
local message = tostring(err)
|
||||||
|
-- Nested effect error already has full thread stack
|
||||||
|
if string.find(message, "^effect error:\n") then return message end
|
||||||
|
return `effect error:\n{debug.traceback(message, 2)}`
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ycall<T, U>(fn: (T) -> U, arg: T): (boolean, string|U)
|
local function ycall<T, U>(fn: (T) -> U, arg: T): (boolean, string|U)
|
||||||
|
|
@ -181,13 +188,13 @@ local function evaluate_node<T>(node: Node<T>)
|
||||||
destroy_owned(node)
|
destroy_owned(node)
|
||||||
|
|
||||||
push_scope(node)
|
push_scope(node)
|
||||||
local ok, new_value = pcall(node.effect :: (T) -> T, node.cache)
|
local ok, new_value = xpcall(node.effect :: (T) -> T, effect_traceback, node.cache)
|
||||||
pop_scope()
|
pop_scope()
|
||||||
|
|
||||||
if not ok then
|
if not ok then
|
||||||
table.clear(update_queue)
|
table.clear(update_queue)
|
||||||
update_queue.n = 0
|
update_queue.n = 0
|
||||||
error(`effect error:\n{new_value}\n`, 0)
|
error(new_value, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
node.cache = new_value
|
node.cache = new_value
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue