Commit 2d1e893b authored by Yossi Gottlieb's avatar Yossi Gottlieb
Browse files

Improve RM_Call() errno classification.

RM_Call() will now use EBADF and ENONET in addition to EINVAL in order
to provide more information about errors (i.e. when return value is
NULL).
parent 64a78f5b
...@@ -3110,7 +3110,9 @@ fmterr: ...@@ -3110,7 +3110,9 @@ fmterr:
* On success a RedisModuleCallReply object is returned, otherwise * On success a RedisModuleCallReply object is returned, otherwise
* NULL is returned and errno is set to the following values: * NULL is returned and errno is set to the following values:
* *
* EINVAL: command non existing, wrong arity, wrong format specifier. * EBADF: wrong format specifier.
* EINVAL: wrong command arity.
* ENOENT: command does not exist.
* EPERM: operation in Cluster instance with key in non local slot. * EPERM: operation in Cluster instance with key in non local slot.
* *
* This API is documented here: https://redis.io/topics/modules-intro * This API is documented here: https://redis.io/topics/modules-intro
...@@ -3142,7 +3144,7 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch ...@@ -3142,7 +3144,7 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch
/* We handle the above format error only when the client is setup so that /* We handle the above format error only when the client is setup so that
* we can free it normally. */ * we can free it normally. */
if (argv == NULL) { if (argv == NULL) {
errno = EINVAL; errno = EBADF;
goto cleanup; goto cleanup;
} }
...@@ -3154,7 +3156,7 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch ...@@ -3154,7 +3156,7 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch
*/ */
cmd = lookupCommand(c->argv[0]->ptr); cmd = lookupCommand(c->argv[0]->ptr);
if (!cmd) { if (!cmd) {
errno = EINVAL; errno = ENOENT;
goto cleanup; goto cleanup;
} }
c->cmd = c->lastcmd = cmd; c->cmd = c->lastcmd = cmd;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment