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
110
test/stacktrace-test.luau
Normal file
110
test/stacktrace-test.luau
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
local vide = require "../"
|
||||
|
||||
do
|
||||
print "============================================================="
|
||||
|
||||
local a = vide.source(1)
|
||||
|
||||
local cause_error = false
|
||||
|
||||
local function try_error()
|
||||
if cause_error then error("uh oh") end
|
||||
end
|
||||
|
||||
vide.root(function()
|
||||
vide.effect(function()
|
||||
a()
|
||||
try_error()
|
||||
end)
|
||||
end)
|
||||
|
||||
cause_error = true
|
||||
|
||||
local ok, result = pcall(function() a(2) end)
|
||||
print(result)
|
||||
|
||||
print "============================================================="
|
||||
end
|
||||
|
||||
do
|
||||
print "============================================================="
|
||||
|
||||
local a = vide.source(1)
|
||||
local b = vide.source(1)
|
||||
local c = vide.source(1)
|
||||
|
||||
local cause_error = false
|
||||
|
||||
local function try_error()
|
||||
if cause_error then error("uh oh") end
|
||||
end
|
||||
|
||||
vide.root(function()
|
||||
vide.effect(function()
|
||||
a()
|
||||
b(vide.untrack(b) + 1)
|
||||
end)
|
||||
|
||||
vide.effect(function()
|
||||
b()
|
||||
c(vide.untrack(c) + 1)
|
||||
end)
|
||||
|
||||
|
||||
vide.effect(function()
|
||||
c()
|
||||
try_error()
|
||||
end)
|
||||
end)
|
||||
|
||||
cause_error = true
|
||||
|
||||
local ok, result = pcall(function() a(2) end)
|
||||
print(result)
|
||||
|
||||
print "============================================================="
|
||||
end
|
||||
|
||||
do
|
||||
print "============================================================="
|
||||
|
||||
local a = vide.source(1)
|
||||
local b = vide.source(1)
|
||||
local c = vide.source(1)
|
||||
|
||||
local cause_error = false
|
||||
|
||||
local function try_error()
|
||||
if cause_error then error("uh oh") end
|
||||
end
|
||||
|
||||
vide.root(function()
|
||||
vide.effect(function()
|
||||
a()
|
||||
vide.untrack(function() -- todo: this trace appearing twice
|
||||
b(b() + 1)
|
||||
return nil
|
||||
end)
|
||||
end)
|
||||
|
||||
vide.effect(function()
|
||||
b()
|
||||
vide.batch(function()
|
||||
c(vide.untrack(c) + 1)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
vide.effect(function()
|
||||
c()
|
||||
try_error()
|
||||
end)
|
||||
end)
|
||||
|
||||
cause_error = true
|
||||
|
||||
local ok, result = pcall(function() a(2) end)
|
||||
print(result)
|
||||
|
||||
print "============================================================="
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue