diff options
author | Oran Agra <oran@redislabs.com> | 2022-04-05 14:25:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-05 14:25:02 +0300 |
commit | fb4e0d400ff82117104bde5296c477ad95f8dd41 (patch) | |
tree | 4ede2d02b134a84ff29bb7398902c398cd4ff454 /src/call_reply.c | |
parent | d2b5a579dd8b785690aa7714df8776ffc452d242 (diff) | |
parent | 8b242ef977b88d6cae38d451130a88116bcbb638 (diff) | |
download | redis-7.0-rc3.tar.gz |
Merge pull request #10532 from oranagra/7.0-rc37.0-rc3
Release 7.0 rc3
Diffstat (limited to 'src/call_reply.c')
-rw-r--r-- | src/call_reply.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/call_reply.c b/src/call_reply.c index 3694db55e..759cd792a 100644 --- a/src/call_reply.c +++ b/src/call_reply.c @@ -525,3 +525,18 @@ CallReply *callReplyCreate(sds reply, list *deferred_error_list, void *private_d res->deferred_error_list = deferred_error_list; return res; } + +/* Create a new CallReply struct from the reply blob representing an error message. + * Automatically creating deferred_error_list and set a copy of the reply in it. + * Refer to callReplyCreate for detailed explanation. */ +CallReply *callReplyCreateError(sds reply, void *private_data) { + sds err_buff = reply; + if (err_buff[0] != '-') { + err_buff = sdscatfmt(sdsempty(), "-ERR %S\r\n", reply); + sdsfree(reply); + } + list *deferred_error_list = listCreate(); + listSetFreeMethod(deferred_error_list, (void (*)(void*))sdsfree); + listAddNodeTail(deferred_error_list, sdsnew(err_buff)); + return callReplyCreate(err_buff, deferred_error_list, private_data); +} |