2
0
mirror of https://github.com/openkmip/pykmip synced 2025-12-15 15:53:36 +00:00

Remove unused error code

This change removes unused exceptions defined in core/errors.py,
along with the errors.py module itself. The few used items from
this file are migrated over to core/exceptions.py. Any dependent
code is updated, dropping the use of errors.py and adding in the
use of exceptions.py.
This commit is contained in:
Peter Hamilton
2017-12-07 20:11:18 -05:00
parent d984c77211
commit 54b1df7726
14 changed files with 247 additions and 220 deletions

View File

@@ -290,3 +290,73 @@ class InvalidPrimitiveLength(Exception):
lengths.
"""
pass
class StreamNotEmptyError(Exception):
def __init__(self, cls, extra):
super(StreamNotEmptyError, self).__init__()
self.cls = cls
self.extra = extra
def __str__(self):
msg = "Invalid length used to read {0}, bytes remaining: {1}"
return msg.format(self.cls, self.extra)
class ReadValueError(Exception):
def __init__(self, cls, attr, exp, recv):
super(ReadValueError, self).__init__()
self.cls = cls
self.attr = attr
self.exp = exp
self.recv = recv
def __str__(self):
msg = "Tried to read {0}.{1}: expected {2}, received {3}"
return msg.format(self.cls, self.attr, self.exp, self.recv)
class WriteOverflowError(Exception):
def __init__(self, cls, attr, exp, recv):
super(WriteOverflowError, self).__init__()
self.cls = cls
self.attr = attr
self.exp = exp
self.recv = recv
def __str__(self):
msg = "Tried to write {0}.{1} with too many bytes: "
msg += "expected {2}, received {3}"
return msg.format(self.cls, self.attr, self.exp, self.recv)
class KMIPServerZombieError(Exception):
"""KMIP server error for hung and persistent live KMIP servers."""
def __init__(self, pid):
super(KMIPServerZombieError, self).__init__()
self.message = 'KMIP server alive after termination: PID {0}'.format(
pid
)
def __str__(self):
return self.message
class KMIPServerSuicideError(Exception):
"""KMIP server error for prematurely dead KMIP servers."""
def __init__(self, pid):
super(KMIPServerSuicideError, self).__init__()
self.message = 'KMIP server dead prematurely: PID {0}'.format(pid)
def __str__(self):
return self.message
class ErrorStrings:
BAD_EXP_RECV = "Bad {0} {1}: expected {2}, received {3}"
BAD_ENCODING = "Bad {0} {1}: encoding mismatch"