Replaced error on nonexisting label name with a more descriptive one
Instead of unintuitive Value Error now we have dedicated QubesLabelNotFoundError. Goal: to make qvm-prefs be less strange when one mixes up gray and grey again.
This commit is contained in:
parent
b506586089
commit
6b9528316f
@ -1340,7 +1340,7 @@ class Qubes(qubes.PropertyHolder):
|
|||||||
except (KeyError, ValueError):
|
except (KeyError, ValueError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
raise KeyError(label)
|
raise qubes.exc.QubesLabelNotFoundError(label)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def setup_pools(self):
|
def setup_pools(self):
|
||||||
|
11
qubes/exc.py
11
qubes/exc.py
@ -208,3 +208,14 @@ class QubesTagNotFoundError(QubesException, KeyError):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
# KeyError overrides __str__ method
|
# KeyError overrides __str__ method
|
||||||
return QubesException.__str__(self)
|
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)
|
||||||
|
@ -82,7 +82,7 @@ class TestApp(qubes.tests.TestEmitter):
|
|||||||
for l in self.labels.values():
|
for l in self.labels.values():
|
||||||
if l.name == label:
|
if l.name == label:
|
||||||
return l
|
return l
|
||||||
raise KeyError(label)
|
raise qubes.exc.QubesLabelNotFoundError(label)
|
||||||
|
|
||||||
def get_pool(self, pool):
|
def get_pool(self, pool):
|
||||||
return self.pools[pool]
|
return self.pools[pool]
|
||||||
|
Loading…
Reference in New Issue
Block a user