mirror of
https://github.com/littensy/charm.git
synced 2026-10-21 03:36:11 +00:00
refactor: catch validation error with pcall
This commit is contained in:
parent
d8d0c2a1f8
commit
a30293ee3b
4 changed files with 22 additions and 59 deletions
|
|
@ -18,11 +18,17 @@ local function diff(previousState: { [any]: any }, nextState: { [any]: any })
|
|||
end
|
||||
|
||||
if _G.__DEV__ then
|
||||
for key, value in previousState do
|
||||
validate(value, key, warn)
|
||||
end
|
||||
for key, value in nextState do
|
||||
validate(value, key, warn)
|
||||
local success, result = pcall(function()
|
||||
for key, value in previousState do
|
||||
validate(value, key)
|
||||
end
|
||||
for key, value in nextState do
|
||||
validate(value, key)
|
||||
end
|
||||
end)
|
||||
|
||||
if not success then
|
||||
warn(result)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue