From 93b8c34053670d575a4f993cebf0bfde787454eb Mon Sep 17 00:00:00 2001 From: Demi Marie Obenour Date: Wed, 17 Feb 2021 22:43:43 -0500 Subject: [PATCH] Better error for read-only properties Previously, the Admin API caller would bet a misleading error message indicating that the property did not exist. --- qubes/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qubes/__init__.py b/qubes/__init__.py index f70f5340..9fac02a0 100644 --- a/qubes/__init__.py +++ b/qubes/__init__.py @@ -409,11 +409,12 @@ class property: # pylint: disable=redefined-builtin,invalid-name This is used to effectively disable property in classes which inherit unwanted property. When someone attempts to load such a property, it - :throws AttributeError: always + :throws qubes.exc.QubesPropertyValueError: always ''' # pylint: disable=bad-staticmethod-argument,unused-argument - raise AttributeError( - 'setting {} property on {} instance is forbidden'.format( + raise qubes.exc.QubesPropertyValueError( + self, self.property_get_def(prop), value, + 'property {!r} on {} instance cannot be set'.format( prop.__name__, self.__class__.__name__))