Bug hunting and polishing

Change-Id: I0f05730dd4e01e926ab0c4870c27ed5754f3ccfd
This commit is contained in:
Enrico Faulhaber
2017-01-20 18:21:27 +01:00
parent 8e3d0da5dd
commit d5e935788f
18 changed files with 552 additions and 202 deletions

View File

@ -30,12 +30,26 @@ class SECOPError(RuntimeError):
for k, v in kwds.items():
setattr(self, k, v)
def __repr__(self):
args = ', '.join(map(repr, self.args))
kwds = ', '.join(['%s=%r' % i for i in self.__dict__.items()])
res = []
if args:
res.append(args)
if kwds:
res.append(kwds)
return '%s(%s)' % (self.name, ', '.join(res))
@property
def name(self):
return self.__class__.__name__[:-len('Error')]
class InternalError(SECOPError):
pass
class ProtocollError(SECOPError):
class ProtocolError(SECOPError):
pass
@ -56,6 +70,10 @@ class ReadonlyError(SECOPError):
pass
class BadValueError(SECOPError):
pass
class CommandFailedError(SECOPError):
pass
@ -64,6 +82,18 @@ class InvalidParamValueError(SECOPError):
pass
EXCEPTIONS = dict(
Internal=InternalError,
Protocol=ProtocolError,
NoSuchModule=NoSuchModuleError,
NoSuchParam=NoSuchParamError,
NoSuchCommand=NoSuchCommandError,
BadValue=BadValueError,
Readonly=ReadonlyError,
CommandFailed=CommandFailedError,
InvalidParam=InvalidParamValueError,
)
if __name__ == '__main__':
print("Minimal testing of errors....")