From: Nikita Pettik <korablev@tarantool.org> To: tarantool-patches@dev.tarantool.org Cc: v.shpilevoy@tarantool.org Subject: [Tarantool-patches] [PATCH v2 02/10] box: rename diag_add_error to diag_set_error Date: Wed, 25 Mar 2020 04:42:58 +0300 [thread overview] Message-ID: <6375dc2c8988baeab588dcf8fb19615441cb94e1.1585097339.git.korablev@tarantool.org> (raw) In-Reply-To: <cover.1585097339.git.korablev@tarantool.org> In-Reply-To: <cover.1585097339.git.korablev@tarantool.org> From: Kirill Shcherbatov <kshcherbatov@tarantool.org> Let's rename diag_add_error() to diag_set_error() because it actually replaces an error object in diagnostic area with a new one and this name is not representative. Moreover, we are going to introduce a new diag_add_error() which will place error at the top of stack diagnostic area. Needed for #1148 --- src/box/applier.cc | 2 +- src/box/error.cc | 2 +- src/box/relay.cc | 4 ++-- src/box/vy_scheduler.c | 6 +++--- src/lib/core/diag.h | 6 +++--- src/lib/core/exception.cc | 2 +- src/lib/core/exception.h | 2 +- src/lua/utils.c | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/box/applier.cc b/src/box/applier.cc index 8666a3a98..47a26c366 100644 --- a/src/box/applier.cc +++ b/src/box/applier.cc @@ -843,7 +843,7 @@ applier_on_rollback(struct trigger *trigger, void *event) struct applier *applier = (struct applier *)trigger->data; /* Setup a shared error. */ if (!diag_is_empty(&replicaset.applier.diag)) { - diag_add_error(&applier->diag, + diag_set_error(&applier->diag, diag_last_error(&replicaset.applier.diag)); } /* Stop the applier fiber. */ diff --git a/src/box/error.cc b/src/box/error.cc index 47dce3305..7dfe1b3ee 100644 --- a/src/box/error.cc +++ b/src/box/error.cc @@ -82,7 +82,7 @@ box_error_set(const char *file, unsigned line, uint32_t code, error_vformat_msg(e, fmt, ap); va_end(ap); } - diag_add_error(&fiber()->diag, e); + diag_set_error(&fiber()->diag, e); return -1; } diff --git a/src/box/relay.cc b/src/box/relay.cc index 95245a3cf..c634348a4 100644 --- a/src/box/relay.cc +++ b/src/box/relay.cc @@ -479,7 +479,7 @@ relay_set_error(struct relay *relay, struct error *e) { /* Don't override existing error. */ if (diag_is_empty(&relay->diag)) - diag_add_error(&relay->diag, e); + diag_set_error(&relay->diag, e); } static void @@ -658,7 +658,7 @@ relay_subscribe_f(va_list ap) * Don't clear the error for status reporting. */ assert(!diag_is_empty(&relay->diag)); - diag_add_error(diag_get(), diag_last_error(&relay->diag)); + diag_set_error(diag_get(), diag_last_error(&relay->diag)); diag_log(); say_crit("exiting the relay loop"); diff --git a/src/box/vy_scheduler.c b/src/box/vy_scheduler.c index acc909d09..bf4c3fe58 100644 --- a/src/box/vy_scheduler.c +++ b/src/box/vy_scheduler.c @@ -619,7 +619,7 @@ vy_scheduler_dump(struct vy_scheduler *scheduler) if (scheduler->is_throttled) { /* Dump error occurred. */ struct error *e = diag_last_error(&scheduler->diag); - diag_add_error(diag_get(), e); + diag_set_error(diag_get(), e); return -1; } fiber_cond_wait(&scheduler->dump_cond); @@ -693,7 +693,7 @@ vy_scheduler_begin_checkpoint(struct vy_scheduler *scheduler) */ if (scheduler->is_throttled) { struct error *e = diag_last_error(&scheduler->diag); - diag_add_error(diag_get(), e); + diag_set_error(diag_get(), e); say_error("cannot checkpoint vinyl, " "scheduler is throttled with: %s", e->errmsg); return -1; @@ -729,7 +729,7 @@ vy_scheduler_wait_checkpoint(struct vy_scheduler *scheduler) if (scheduler->is_throttled) { /* A dump error occurred, abort checkpoint. */ struct error *e = diag_last_error(&scheduler->diag); - diag_add_error(diag_get(), e); + diag_set_error(diag_get(), e); say_error("vinyl checkpoint failed: %s", e->errmsg); return -1; } diff --git a/src/lib/core/diag.h b/src/lib/core/diag.h index f763957c2..7e1e1a174 100644 --- a/src/lib/core/diag.h +++ b/src/lib/core/diag.h @@ -168,12 +168,12 @@ diag_clear(struct diag *diag) } /** - * Add a new error to the diagnostics area + * Set a new error to the diagnostics area, replacing existent. * \param diag diagnostics area * \param e error to add */ static inline void -diag_add_error(struct diag *diag, struct error *e) +diag_set_error(struct diag *diag, struct error *e) { assert(e != NULL); error_ref(e); @@ -275,7 +275,7 @@ BuildSocketError(const char *file, unsigned line, const char *socketname, say_debug("%s at %s:%i", #class, __FILE__, __LINE__); \ struct error *e; \ e = Build##class(__FILE__, __LINE__, ##__VA_ARGS__); \ - diag_add_error(diag_get(), e); \ + diag_set_error(diag_get(), e); \ /* Restore the errno which might have been reset. */ \ errno = save_errno; \ } while (0) diff --git a/src/lib/core/exception.cc b/src/lib/core/exception.cc index 76dcea553..0ab10c4bd 100644 --- a/src/lib/core/exception.cc +++ b/src/lib/core/exception.cc @@ -99,7 +99,7 @@ Exception::operator new(size_t size) void *buf = malloc(size); if (buf != NULL) return buf; - diag_add_error(diag_get(), &out_of_memory); + diag_set_error(diag_get(), &out_of_memory); throw &out_of_memory; } diff --git a/src/lib/core/exception.h b/src/lib/core/exception.h index d6154eb32..1947b4f00 100644 --- a/src/lib/core/exception.h +++ b/src/lib/core/exception.h @@ -177,7 +177,7 @@ exception_init(); #define tnt_error(class, ...) ({ \ say_debug("%s at %s:%i", #class, __FILE__, __LINE__); \ class *e = new class(__FILE__, __LINE__, ##__VA_ARGS__); \ - diag_add_error(diag_get(), e); \ + diag_set_error(diag_get(), e); \ e; \ }) diff --git a/src/lua/utils.c b/src/lua/utils.c index de14c778c..54d18ac89 100644 --- a/src/lua/utils.c +++ b/src/lua/utils.c @@ -1022,7 +1022,7 @@ luaT_toerror(lua_State *L) struct error *e = luaL_iserror(L, -1); if (e != NULL) { /* Re-throw original error */ - diag_add_error(&fiber()->diag, e); + diag_set_error(&fiber()->diag, e); } else { /* Convert Lua error to a Tarantool exception. */ diag_set(LuajitError, luaT_tolstring(L, -1, NULL)); -- 2.17.1
next prev parent reply other threads:[~2020-03-25 1:43 UTC|newest] Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-25 1:42 [Tarantool-patches] [PATCH v2 00/10] Stacked diagnostics Nikita Pettik 2020-03-25 1:42 ` [Tarantool-patches] [PATCH v2 01/10] box: rfc for stacked diagnostic area Nikita Pettik 2020-03-25 8:27 ` Konstantin Osipov 2020-03-25 14:08 ` Nikita Pettik 2020-03-25 1:42 ` Nikita Pettik [this message] 2020-03-25 8:27 ` [Tarantool-patches] [PATCH v2 02/10] box: rename diag_add_error to diag_set_error Konstantin Osipov 2020-03-26 0:22 ` Vladislav Shpilevoy 2020-03-26 12:31 ` Nikita Pettik 2020-03-25 1:42 ` [Tarantool-patches] [PATCH v2 03/10] test: move box.error tests to box/error.test.lua Nikita Pettik 2020-03-25 8:28 ` Konstantin Osipov 2020-03-26 0:22 ` Vladislav Shpilevoy 2020-03-26 12:31 ` Nikita Pettik 2020-03-25 1:43 ` [Tarantool-patches] [PATCH v2 04/10] box/error: introduce box.error.set() method Nikita Pettik 2020-03-25 8:33 ` Konstantin Osipov 2020-03-25 17:41 ` Nikita Pettik 2020-03-26 0:22 ` Vladislav Shpilevoy 2020-03-26 12:31 ` Nikita Pettik 2020-03-25 1:43 ` [Tarantool-patches] [PATCH v2 05/10] box/error: don't set error created via box.error.new to diag Nikita Pettik 2020-03-26 16:50 ` Konstantin Osipov 2020-03-26 17:59 ` Nikita Pettik 2020-03-26 18:06 ` Nikita Pettik 2020-03-26 18:07 ` Alexander Turenko 2020-03-27 0:19 ` Vladislav Shpilevoy 2020-03-27 13:09 ` Nikita Pettik 2020-03-25 1:43 ` [Tarantool-patches] [PATCH v2 06/10] box: introduce stacked diagnostic area Nikita Pettik 2020-03-26 16:54 ` Konstantin Osipov 2020-03-26 18:03 ` Nikita Pettik 2020-03-26 18:08 ` Konstantin Osipov 2020-03-28 18:40 ` Vladislav Shpilevoy 2020-04-01 16:09 ` Nikita Pettik 2020-04-02 0:29 ` Vladislav Shpilevoy 2020-04-02 17:42 ` Nikita Pettik 2020-04-02 22:20 ` Vladislav Shpilevoy 2020-04-03 1:54 ` Nikita Pettik 2020-04-03 23:17 ` Vladislav Shpilevoy 2020-03-28 18:59 ` Vladislav Shpilevoy 2020-03-31 17:44 ` Nikita Pettik 2020-04-02 0:29 ` Vladislav Shpilevoy 2020-04-02 14:16 ` Nikita Pettik 2020-03-25 1:43 ` [Tarantool-patches] [PATCH v2 07/10] box: use stacked diagnostic area for functional indexes Nikita Pettik 2020-03-30 23:24 ` Vladislav Shpilevoy 2020-04-01 15:53 ` Nikita Pettik 2020-03-25 1:43 ` [Tarantool-patches] [PATCH v2 08/10] box/error: clarify purpose of reference counting in struct error Nikita Pettik 2020-03-30 23:24 ` Vladislav Shpilevoy 2020-03-25 1:43 ` [Tarantool-patches] [PATCH v2 09/10] iproto: refactor error encoding with mpstream Nikita Pettik 2020-03-30 23:24 ` Vladislav Shpilevoy 2020-04-01 15:54 ` Nikita Pettik 2020-03-25 1:43 ` [Tarantool-patches] [PATCH v2 10/10] iproto: support error stacked diagnostic area Nikita Pettik 2020-03-30 23:24 ` Vladislav Shpilevoy 2020-04-01 16:26 ` Nikita Pettik 2020-04-01 22:24 ` Nikita Pettik 2020-04-02 0:29 ` Vladislav Shpilevoy 2020-04-02 14:01 ` Nikita Pettik 2020-04-02 22:20 ` Vladislav Shpilevoy 2020-04-03 2:16 ` Nikita Pettik 2020-04-03 23:17 ` Vladislav Shpilevoy 2020-04-06 11:07 ` Nikita Pettik
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=6375dc2c8988baeab588dcf8fb19615441cb94e1.1585097339.git.korablev@tarantool.org \ --to=korablev@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 02/10] box: rename diag_add_error to diag_set_error' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox