mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
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.
This commit is contained in:
parent
2705306ba1
commit
8eae54aa1e
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user