diff options
author | Binbin <binloveplay1314@qq.com> | 2023-04-12 15:11:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-12 10:11:29 +0300 |
commit | bfec2d700b8b0ccf6669e0408b5c5c75299ef47e (patch) | |
tree | 04e20c7adfdb2738f59f50f9fcc5c3f43e272556 /src/redismodule.h | |
parent | 997fa41e99271cc5c3a79e9bf8a1332b3d9ab0c2 (diff) | |
download | redis-bfec2d700b8b0ccf6669e0408b5c5c75299ef47e.tar.gz |
Add RM_ReplyWithErrorFormat that can support format (#11923)
* Add RM_ReplyWithErrorFormat that can support format
Reply with the error create from a printf format and arguments.
If the error code is already passed in the string 'fmt', the error
code provided is used, otherwise the string "-ERR " for the generic
error code is automatically added.
The usage is, for example:
RedisModule_ReplyWithErrorFormat(ctx, "An error: %s", "foo");
RedisModule_ReplyWithErrorFormat(ctx, "-WRONGTYPE Wrong Type: %s", "foo");
The function always returns REDISMODULE_OK.
Diffstat (limited to 'src/redismodule.h')
-rw-r--r-- | src/redismodule.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/redismodule.h b/src/redismodule.h index f58da2f49..fff6ac9bc 100644 --- a/src/redismodule.h +++ b/src/redismodule.h @@ -1014,6 +1014,7 @@ REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringPrintf)(RedisModul REDISMODULE_API void (*RedisModule_FreeString)(RedisModuleCtx *ctx, RedisModuleString *str) REDISMODULE_ATTR; REDISMODULE_API const char * (*RedisModule_StringPtrLen)(const RedisModuleString *str, size_t *len) REDISMODULE_ATTR; REDISMODULE_API int (*RedisModule_ReplyWithError)(RedisModuleCtx *ctx, const char *err) REDISMODULE_ATTR; +REDISMODULE_API int (*RedisModule_ReplyWithErrorFormat)(RedisModuleCtx *ctx, const char *fmt, ...) REDISMODULE_ATTR; REDISMODULE_API int (*RedisModule_ReplyWithSimpleString)(RedisModuleCtx *ctx, const char *msg) REDISMODULE_ATTR; REDISMODULE_API int (*RedisModule_ReplyWithArray)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; REDISMODULE_API int (*RedisModule_ReplyWithMap)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; @@ -1332,6 +1333,7 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int REDISMODULE_GET_API(WrongArity); REDISMODULE_GET_API(ReplyWithLongLong); REDISMODULE_GET_API(ReplyWithError); + REDISMODULE_GET_API(ReplyWithErrorFormat); REDISMODULE_GET_API(ReplyWithSimpleString); REDISMODULE_GET_API(ReplyWithArray); REDISMODULE_GET_API(ReplyWithMap); |