Commit e5b973ef authored by Vincent Pelletier's avatar Vincent Pelletier

Decode error codes properly, now that they became EnumItems.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1100 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 0bfacc9e
...@@ -508,6 +508,12 @@ def _decodeNodeType(original_node_type): ...@@ -508,6 +508,12 @@ def _decodeNodeType(original_node_type):
raise PacketMalformedError('invalid node type %d' % original_node_type) raise PacketMalformedError('invalid node type %d' % original_node_type)
return node_type return node_type
def _decodeErrorCode(original_error_code):
error_code = error_codes.get(original_error_code)
if error_code is None:
raise PacketMalformedError('invalid error code %d' % original_error_code)
return error_code
def _decodeAddress(address): def _decodeAddress(address):
if address == '\0' * 6: if address == '\0' * 6:
return None return None
...@@ -561,6 +567,7 @@ def _readString(buf, name, offset=0): ...@@ -561,6 +567,7 @@ def _readString(buf, name, offset=0):
@handle_errors @handle_errors
def _decodeError(body): def _decodeError(body):
(code, ) = unpack('!H', body[:2]) (code, ) = unpack('!H', body[:2])
code = _decodeErrorCode(code)
(message, _) = _readString(body, 'message', offset=2) (message, _) = _readString(body, 'message', offset=2)
return (code, message) return (code, message)
decode_table[ERROR] = _decodeError decode_table[ERROR] = _decodeError
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment