mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00: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:
parent
f1c8ca1a66
commit
ff57e785f8
@ -22,10 +22,15 @@ class DevlibError(Exception):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def message(self):
|
def message(self):
|
||||||
if self._message is not None:
|
try:
|
||||||
return self._message
|
msg = self._message
|
||||||
else:
|
except AttributeError:
|
||||||
|
msg = None
|
||||||
|
|
||||||
|
if msg is None:
|
||||||
return str(self)
|
return str(self)
|
||||||
|
else:
|
||||||
|
return self._message
|
||||||
|
|
||||||
|
|
||||||
class DevlibStableError(DevlibError):
|
class DevlibStableError(DevlibError):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user