summaryrefslogtreecommitdiff
path: root/redis/exceptions.py
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2013-12-08 18:49:37 -0800
committerAndy McCurdy <andy@andymccurdy.com>2013-12-08 18:49:37 -0800
commit81a4a31779af0a608dcd04bfc3d33995aaa87272 (patch)
treeaf8503e00072acda5113c18a40cf4b6c07d0d95c /redis/exceptions.py
parent27d7f152fcab84bbe71c57892644260f0b0c7219 (diff)
downloadredis-py-81a4a31779af0a608dcd04bfc3d33995aaa87272.tar.gz
Add extra info to exceptions raised in pipelines. Fixes #407
ResponseErrors generated by commands executed in a pipeline now includes the command position in the pipeline and the actual command sent to the Redis server. For example: Command # 3 (LPUSH c 3) of pipeline caused error: <actual error message from Redis server>
Diffstat (limited to 'redis/exceptions.py')
-rw-r--r--redis/exceptions.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/redis/exceptions.py b/redis/exceptions.py
index d67afa7..0b64f91 100644
--- a/redis/exceptions.py
+++ b/redis/exceptions.py
@@ -1,10 +1,21 @@
"Core exceptions raised by the Redis client"
+from redis._compat import unicode
class RedisError(Exception):
pass
+# python 2.5 doesn't implement Exception.__unicode__. Add it here to all
+# our exception types
+if not hasattr(RedisError, '__unicode__'):
+ def __unicode__(self):
+ if isinstance(self.args[0], unicode):
+ return self.args[0]
+ return unicode(self.args[0])
+ RedisError.__unicode__ = __unicode__
+
+
class AuthenticationError(RedisError):
pass