Skip to content

Commit

Permalink
ResponseError raising is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
kmike committed Apr 13, 2011
1 parent f98f7ff commit 1605c75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 5 additions & 7 deletions brukva/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def format_reply(self, cmd_line, data):
except Exception, e:
raise ResponseError(
'failed to format reply to %s, raw data: %s; err message: %s' %
cmd_line, data, e
(cmd_line, data, e), cmd_line
)
return res
####
Expand Down Expand Up @@ -396,9 +396,7 @@ def process_data(self, data, cmd_line, callback):
tail = tail[4:]
response = ResponseError(tail, cmd_line)
else:
raise ResponseError('Unknown response type %s' %
(head, cmd_line)
)
raise ResponseError('Unknown response type %s' % head, cmd_line)

callback(response)

Expand All @@ -412,7 +410,7 @@ def consume_multibulk(self, length, cmd_line, callback):
if not data:
raise ResponseError(
'Not enough data in response to %s, accumulated tokens: %s'%
(cmd_line, tokens)
(cmd_line, tokens), cmd_line
)
token = yield self.process_data(data, cmd_line) #FIXME error
tokens.append( token )
Expand All @@ -426,7 +424,7 @@ def consume_bulk(self, length, callback):
if isinstance(data, Exception):
raise data
if not data:
raise ResponseError('EmptyResponse')
raise ResponseError('EmptyResponse', None)
else:
data = data[:-2]
callback(data)
Expand Down Expand Up @@ -892,7 +890,7 @@ def execute(self, callbacks):
while len(responses) < total:
data = yield async(self.connection.readline)()
if not data:
raise ResponseError('Not enough data after EXEC')
raise ResponseError('Not enough data after EXEC', None)

try:
cmd_line = cmds.next()
Expand Down
4 changes: 3 additions & 1 deletion brukva/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def __init__(self, message, cmd_line):
self.cmd_line = cmd_line

def __repr__(self):
return 'ResponseError (on %s [%s, %s]): %s' % (self.cmd_line.cmd, self.cmd_line.args, self.cmd_line.kwargs, self.message)
if self.cmd_line:
return 'ResponseError (on %s [%s, %s]): %s' % (self.cmd_line.cmd, self.cmd_line.args, self.cmd_line.kwargs, self.message)
return 'ResponseError: %s' % self.message

__str__ = __repr__

Expand Down

0 comments on commit 1605c75

Please sign in to comment.