Use ValueError in PropertyHolder.property_require()

Specifically do not use AssertionError, but also be consistent with
other value verification.
This commit is contained in:
Marek Marczykowski-Górecki 2018-10-29 20:16:41 +01:00
parent 4e49b951ce
commit c1c6dc2acd
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -728,12 +728,12 @@ class PropertyHolder(qubes.events.Emitter):
try:
value = getattr(self, prop)
if value is None and not allow_none:
raise AttributeError()
raise ValueError('Property {!r} cannot be None'.format(prop))
except AttributeError:
# pylint: disable=no-member
msg = 'Required property {!r} not set on {!r}'.format(prop, self)
if hard:
raise AssertionError(msg)
raise ValueError(msg)
else:
# pylint: disable=no-member
self.log.fatal(msg)