diff --git a/qubes/app.py b/qubes/app.py index f22037d1..42c9bb12 100644 --- a/qubes/app.py +++ b/qubes/app.py @@ -1340,7 +1340,7 @@ class Qubes(qubes.PropertyHolder): except (KeyError, ValueError): pass - raise KeyError(label) + raise qubes.exc.QubesLabelNotFoundError(label) @asyncio.coroutine def setup_pools(self): diff --git a/qubes/exc.py b/qubes/exc.py index ef64f513..75992c5b 100644 --- a/qubes/exc.py +++ b/qubes/exc.py @@ -208,3 +208,14 @@ class QubesTagNotFoundError(QubesException, KeyError): def __str__(self): # KeyError overrides __str__ method return QubesException.__str__(self) + + +class QubesLabelNotFoundError(QubesException, KeyError): + """Label does not exists""" + def __init__(self, label): + super().__init__('Label does not exist: {}'.format(label)) + self.label = label + + def __str__(self): + # KeyError overrides __str__ method + return QubesException.__str__(self) diff --git a/qubes/tests/vm/__init__.py b/qubes/tests/vm/__init__.py index a152759b..51e20ce7 100644 --- a/qubes/tests/vm/__init__.py +++ b/qubes/tests/vm/__init__.py @@ -82,7 +82,7 @@ class TestApp(qubes.tests.TestEmitter): for l in self.labels.values(): if l.name == label: return l - raise KeyError(label) + raise qubes.exc.QubesLabelNotFoundError(label) def get_pool(self, pool): return self.pools[pool]