From 843cf68c1a50112fe397fe91b8ac915fb88a8def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 10 Feb 2016 16:50:11 +0100 Subject: [PATCH] core: return QubesVMNotFoundError when setting non-existent VM to VMProperty Not sure about this one. Maybe it should be rather QubesPropertyValueError? --- qubes/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qubes/__init__.py b/qubes/__init__.py index b72ba98f..560388c5 100644 --- a/qubes/__init__.py +++ b/qubes/__init__.py @@ -1061,9 +1061,10 @@ class VMProperty(property): app = instance if isinstance(instance, Qubes) else instance.app - # XXX this may throw LookupError; that's good until introduction - # of QubesNoSuchVMException or whatever - vm = app.domains[value] + try: + vm = app.domains[value] + except KeyError: + raise qubes.exc.QubesVMNotFoundError(value) if not isinstance(vm, self.vmclass): raise TypeError('wrong VM class: domains[{!r}] if of type {!s} '