Skip to content

Commit

Permalink
Merge pull request #669 from th13f/master
Browse files Browse the repository at this point in the history
parsing 'max number of clients reached' as ConnectionError
  • Loading branch information
andymccurdy committed Nov 2, 2015
2 parents 93ee0b9 + 01460eb commit 7360a0d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions redis/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ def __str__(self):

class BaseParser(object):
EXCEPTION_CLASSES = {
'ERR': ResponseError,
'ERR': {
'default': ResponseError,
'max number of clients reached': ConnectionError
},
'EXECABORT': ExecAbortError,
'LOADING': BusyLoadingError,
'NOSCRIPT': NoScriptError,
Expand All @@ -92,7 +95,14 @@ def parse_error(self, response):
error_code = response.split(' ')[0]
if error_code in self.EXCEPTION_CLASSES:
response = response[len(error_code) + 1:]
return self.EXCEPTION_CLASSES[error_code](response)
exception_class = self.EXCEPTION_CLASSES[error_code]
if isinstance(exception_class, dict):
return exception_class.get(
response,
exception_class['default']
)(response)
else:
return exception_class(response)
return ResponseError(response)


Expand Down

0 comments on commit 7360a0d

Please sign in to comment.