summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-03-10 23:01:55 +0100
committerantirez <antirez@gmail.com>2014-03-11 11:10:33 +0100
commit01eee56f4f0d8bdc2decdcf527417b4de48411bc (patch)
tree38f9c038a0668fad5d741ebfe66c9ce229ba1519
parentab8e1bbcdcf3756255c956f3c50a8c5c822dd4c3 (diff)
downloadredis-01eee56f4f0d8bdc2decdcf527417b4de48411bc.tar.gz
DEBUG ERROR implemented.
The new "error" subcommand of the DEBUG command can reply with an user selected error, specified as its sole argument: DEBUG ERROR "LOADING please wait..." The error is generated just prefixing the command argument with a "-" character, and replacing newlines with spaces (since error replies can't include newlines). The goal of the command is to help in Client libraries unit tests by making simple to simulate a command call triggering a given error.
-rw-r--r--src/debug.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/debug.c b/src/debug.c
index 198334b9d..5068c4836 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -381,6 +381,13 @@ void debugCommand(redisClient *c) {
addReplyMultiBulkLen(c,numkeys);
for (j = 0; j < numkeys; j++) addReplyBulk(c,c->argv[keys[j]+2]);
getKeysFreeResult(keys);
+ } else if (!strcasecmp(c->argv[1]->ptr,"error") && c->argc == 3) {
+ sds errstr = sdsnewlen("-",1);
+
+ errstr = sdscatsds(errstr,c->argv[2]->ptr);
+ errstr = sdsmapchars(errstr,"\n\r"," ",2); /* no newlines in errors. */
+ errstr = sdscatlen(errstr,"\r\n",2);
+ addReplySds(c,errstr);
} else {
addReplyErrorFormat(c, "Unknown DEBUG subcommand or wrong number of arguments for '%s'",
(char*)c->argv[1]->ptr);