--- lib/cli.py | 4 ++-- lib/luxi.py | 17 +++++------------ 2 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/lib/cli.py b/lib/cli.py index cbf6561..8de87dd 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -1301,8 +1301,6 @@ def FormatError(err): obuf.write("Parameter Error: %s" % msg) elif isinstance(err, errors.ParameterError): obuf.write("Failure: unknown/wrong parameter name '%s'" % msg) - elif isinstance(err, errors.GenericError): - obuf.write("Unhandled Ganeti error: %s" % msg) elif isinstance(err, luxi.NoMasterError): obuf.write("Cannot communicate with the master daemon.\nIs it running" " and listening for connections?") @@ -1312,6 +1310,8 @@ def FormatError(err): elif isinstance(err, luxi.ProtocolError): obuf.write("Unhandled protocol error while talking to the master daemon:\n" "%s" % msg) + elif isinstance(err, errors.GenericError): + obuf.write("Unhandled Ganeti error: %s" % msg) elif isinstance(err, JobSubmittedException): obuf.write("JobID: %s\n" % err.args[0]) retcode = 0 diff --git a/lib/luxi.py b/lib/luxi.py index f062816..414be06 100644 --- a/lib/luxi.py +++ b/lib/luxi.py @@ -64,8 +64,8 @@ DEF_CTMO = 10 DEF_RWTO = 60 -class ProtocolError(Exception): - """Denotes an error in the server communication""" +class ProtocolError(errors.GenericError): + """Denotes an error in the LUXI protocol""" class ConnectionClosedError(ProtocolError): @@ -76,14 +76,6 @@ class TimeoutError(ProtocolError): """Operation timeout error""" -class EncodingError(ProtocolError): - """Encoding failure on the sending side""" - - -class DecodingError(ProtocolError): - """Decoding failure on the receiving side""" - - class RequestError(ProtocolError): """Error on request @@ -186,7 +178,8 @@ class Transport: """ if self.eom in msg: - raise EncodingError("Message terminator found in payload") + raise ProtocolError("Message terminator found in payload") + self._CheckSocket() try: # TODO: sendall is not guaranteed to send everything @@ -321,7 +314,7 @@ class Client(object): if (not isinstance(data, dict) or KEY_SUCCESS not in data or KEY_RESULT not in data): - raise DecodingError("Invalid response from server: %s" % str(data)) + raise ProtocolError("Invalid response from server: %s" % str(data)) result = data[KEY_RESULT] -- 1.6.4.3