diff --git a/plugin/src/Reconciler.lua b/plugin/src/Reconciler.lua index db0728e2..df925325 100644 --- a/plugin/src/Reconciler.lua +++ b/plugin/src/Reconciler.lua @@ -67,15 +67,34 @@ local function setProperty(instance, key, value) return end - local ok, err = pcall(function() - if instance[key] ~= value then + -- If we don't have permissions to access this value at all, we can skip it. + local readSuccess, existingValue = pcall(function() + return instance[key] + end) + + if not readSuccess then + -- An error will be thrown if there was a permission issue or if the + -- property doesn't exist. In the latter case, we should tell the user + -- because it's probably their fault. + if existingValue:find("lacking permission") then + Logging.trace("Permission error reading property %s on class %s", tostring(key), instance.ClassName) + return + else + error(("Invalid property %s on class %s: %s"):format(tostring(key), instance.ClassName, existingValue), 2) + end + end + + local writeSuccess, err = pcall(function() + if existingValue ~= value then instance[key] = value end end) - if not ok then + if not writeSuccess then error(("Cannot set property %s on class %s: %s"):format(tostring(key), instance.ClassName, err), 2) end + + return true end local Reconciler = {}