Skip to content

Commit

Permalink
Fix error message of SETEX/PSETEX
Browse files Browse the repository at this point in the history
This is a rewritten version of #811

Closes #811
  • Loading branch information
mattsta committed Aug 2, 2014
1 parent e8fb537 commit 2a0c018
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/t_string.c
Expand Up @@ -29,6 +29,7 @@

#include "redis.h"
#include <math.h> /* isnan(), isinf() */
#include <ctype.h> /* tolower() */

/*-----------------------------------------------------------------------------
* String Commands
Expand Down Expand Up @@ -69,7 +70,10 @@ void setGenericCommand(redisClient *c, int flags, robj *key, robj *val, robj *ex
if (getLongLongFromObjectOrReply(c, expire, &milliseconds, NULL) != REDIS_OK)
return;
if (milliseconds <= 0) {
addReplyError(c,"invalid expire time in SETEX");
char *set = "SETEX", *pset = "PSETEX";
char *cmd = c->argv[0]->ptr;
char *proper_name = tolower(*cmd) == 's' ? set : pset;
addReplyErrorFormat(c, "invalid expire time in %s", proper_name);
return;
}
if (unit == UNIT_SECONDS) milliseconds *= 1000;
Expand Down

0 comments on commit 2a0c018

Please sign in to comment.