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/networking.c | |
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/networking.c')
-rw-r--r-- | src/networking.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/networking.c b/src/networking.c index 7fa18af48..574773b37 100644 --- a/src/networking.c +++ b/src/networking.c @@ -620,9 +620,9 @@ void addReplyErrorSdsSafe(client *c, sds err) { addReplyErrorSdsEx(c, err, 0); } -/* Internal function used by addReplyErrorFormat and addReplyErrorFormatEx. +/* Internal function used by addReplyErrorFormat, addReplyErrorFormatEx and RM_ReplyWithErrorFormat. * Refer to afterErrorReply for more information about the flags. */ -static void addReplyErrorFormatInternal(client *c, int flags, const char *fmt, va_list ap) { +void addReplyErrorFormatInternal(client *c, int flags, const char *fmt, va_list ap) { va_list cpy; va_copy(cpy,ap); sds s = sdscatvprintf(sdsempty(),fmt,cpy); |