1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-05 18:30:50 +01:00

exception: Deal with missing _message attribute

Allow subclasses of DevlibError to not have a _message attribute, in
which case it falls back on str(self), just as when _message is None.
This commit is contained in:
Douglas Raillard 2021-09-28 14:37:46 +01:00 committed by Marc Bonnici
parent f1c8ca1a66
commit ff57e785f8

View File

@ -22,10 +22,15 @@ class DevlibError(Exception):
@property
def message(self):
if self._message is not None:
return self._message
else:
try:
msg = self._message
except AttributeError:
msg = None
if msg is None:
return str(self)
else:
return self._message
class DevlibStableError(DevlibError):