mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-25 23:26:19 +00:00
plugin: Update to newer rbx-dom with better error handling
This commit is contained in:
Submodule plugin/modules/rbx-dom updated: ac129152f2...74ec3e7d88
@@ -7,20 +7,6 @@ local function rojoValueToRobloxValue(value)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: Remove this once rbx_dom_weak and rbx_dom_lua agree on encoding
|
|
||||||
if value.Type == "BinaryString" then
|
|
||||||
local actualValue = ""
|
|
||||||
|
|
||||||
for i = 1, #value.Value do
|
|
||||||
actualValue = actualValue .. string.char(i)
|
|
||||||
end
|
|
||||||
|
|
||||||
value = {
|
|
||||||
Type = "BinaryString",
|
|
||||||
Value = actualValue,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
local success, decodedValue = RbxDom.EncodedValue.decode(value)
|
local success, decodedValue = RbxDom.EncodedValue.decode(value)
|
||||||
|
|
||||||
if not success then
|
if not success then
|
||||||
|
|||||||
@@ -1,34 +1,32 @@
|
|||||||
local RbxDom = require(script:FindFirstAncestor("Rojo").RbxDom)
|
local RbxDom = require(script:FindFirstAncestor("Rojo").RbxDom)
|
||||||
|
|
||||||
local Logging = require(script.Parent.Logging)
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Attempts to set a property on the given instance.
|
Attempts to set a property on the given instance.
|
||||||
]]
|
]]
|
||||||
local function setCanonicalProperty(instance, key, value)
|
local function setCanonicalProperty(instance, key, value)
|
||||||
if not RbxDom.CanonicalProperty.isScriptable(instance.ClassName, key) then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If we don't have permissions to access this value at all, we can skip it.
|
-- If we don't have permissions to access this value at all, we can skip it.
|
||||||
local readSuccess, existingValue = RbxDom.CanonicalProperty.read(instance, key)
|
local readSuccess, existingValue = RbxDom.readProperty(instance, key)
|
||||||
|
|
||||||
if not readSuccess then
|
if not readSuccess then
|
||||||
-- An error will be thrown if there was a permission issue or if the
|
if existingValue.kind == RbxDom.Error.Kind.UnknownProperty
|
||||||
-- property doesn't exist. In the latter case, we should tell the user
|
or existingValue.kind == RbxDom.Error.Kind.PropertyNotReadable then
|
||||||
-- because it's probably their fault.
|
-- this is fine
|
||||||
if existingValue:find("lacking permission") then
|
|
||||||
Logging.trace("Permission error reading property %s on class %s", tostring(key), instance.ClassName)
|
|
||||||
return false
|
return false
|
||||||
else
|
|
||||||
error(("Invalid property %s on class %s: %s"):format(tostring(key), instance.ClassName, existingValue), 2)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- If we don't have permission to write a property, we just silently
|
||||||
|
-- ignore it.
|
||||||
|
if existingValue.kind == RbxDom.Error.Kind.Roblox and existingValue.extra:find("lacking permission") then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
error(("Invalid property %s on class %s: %s"):format(tostring(key), instance.ClassName, tostring(existingValue)), 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
local writeSuccess, err = RbxDom.CanonicalProperty.write(instance, key, value)
|
local writeSuccess, err = RbxDom.writeProperty(instance, key, value)
|
||||||
|
|
||||||
if not writeSuccess then
|
if not writeSuccess then
|
||||||
error(("Cannot set property %s on class %s: %s"):format(tostring(key), instance.ClassName, err), 2)
|
error(("Cannot set property %s on class %s: %s"):format(tostring(key), instance.ClassName, tostring(err)), 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
Reference in New Issue
Block a user