From eb9e1526e65b01ba6041003878c9702c5670e11b Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 10 Mar 2014 23:01:55 +0100 Subject: [PATCH] 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. --- src/debug.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/debug.c b/src/debug.c index 032653fb..0cc8dcf2 100644 --- a/src/debug.c +++ b/src/debug.c @@ -363,6 +363,13 @@ void debugCommand(redisClient *c) { { server.active_expire_enabled = atoi(c->argv[2]->ptr); addReply(c,shared.ok); + } 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); -- GitLab