From: lvasiliev <lvasiliev@tarantool.org> To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH v2 2/5] error: Add the custom error type Date: Thu, 16 Apr 2020 12:18:51 +0300 [thread overview] Message-ID: <428aeafc-58b5-899d-b62e-bf08853d3366@tarantool.org> (raw) In-Reply-To: <2b4b8329-437a-429e-577b-8e1bb49d14c1@tarantool.org> Hi! Thanks you for the feedback. On 16.04.2020 3:02, Vladislav Shpilevoy wrote: > Thanks for the fixes! > >>> 6. Make_type() perfectly fits in one line. >>> >>>> + >>>> +CustomError::CustomError(const char *file, unsigned int line, >>>> + const char *custom_type) >>>> + :ClientError(&type_CustomError, file, line, ER_CUSTOM_ERROR) >>>> +{ >>>> + error_format_msg(this, tnt_errcode_desc(m_errcode), >>>> + custom_type ?: ""); >>> >>> 7. custom_type is never NULL. >> Why? It's a constructor argument. > > And still it is never NULL. I couldn't find any place, where > you passed NULL here, and anyway that would be incorrect. Type > can't be just NULL. How to present it in Lua then? nil? Doubt > it. Hmm, ok. > >>>> + */ >>>> +const char * >>>> +box_custom_error_type(const box_error_t *e); >>>> + >>>> +/** >>>> * Add error to the diagnostic area. In contrast to box_error_set() >>>> * it does not replace previous error being set, but rather link >>>> * them into list. >>>> @@ -155,15 +166,24 @@ box_error_add(const char *file, unsigned line, uint32_t code, >>>> /** >>>> * Construct error object without setting it in the diagnostics >>>> - * area. On the memory allocation fail returns NULL. >>>> + * area. On the memory allocation fail returns OutOfMemory error. >>> >>> 10. Unneccessary diff. >> The comment is wrong. How I can fix it? > > Yeah, I just realized that after you said box_error_new() never > returns NULL. Then probably it is ok to change it. Ok. I will replace it in the new version of the patchset. > >>> >>>> */ >>>> struct error * >>>> box_error_new(const char *file, unsigned line, uint32_t code, >>>> const char *fmt, ...); >>>> +/** >>>> + * Construct error object without setting it in the diagnostics >>>> + * area. On the memory allocation fail returns OutOfMemory error. >>> >>> 11. This is a copy-paste box box_error_new() comment. Better write >>> here a couple of words how is it different. Or better merge box_error_new() >>> and box_custom_error_new(). Because in Lua I can specify both code >>> and type. Don't see why can't I do this in C. >> I thought we can’t change public API. > > This is not public API. If something is not compiled into module.h, > it is not public (in C. For Lua rules are different). > >>>> @@ -111,9 +148,16 @@ raise: >>>> line = info.currentline; >>>> } >>>> - struct error *err = box_error_new(file, line, code, "%s", reason); >>>> - if (tb_parsed) >>>> - err->traceback_mode = tb_mode; >>>> + struct error *err = NULL; >>>> + if (args.custom) { >>>> + err = box_custom_error_new(file, line, args.custom, >>>> + "%s", args.reason); >>> >>> 18. Code argument is ignored here. Although I am not sure it shouldn't >>> be ignored. From what I remember, we decided that code should stay, >>> but I may be wrong. >> CustomError type has a predefinded code. Why it shouldn't be ignored? > > Because it is not a 'ClientError' object from user's point of view. The > fact that we implemented it as a descendant of 'ClientError' class should > not leak into the API. User can't assume anything about error hierarchies. > He does not even see them. > > From user's point of view there are separate built-in 'ClientError'. And > separate 'CustomError'. Both accept error code now. But 'CustomError' > ignores it somewhy. Does not look right. > No, from user's point of view it have only type without any codes (In accordance with the task). Besides, I think it's strange to have an AccessDeniedError with code "ER_SQL_PREPARE" (other branch of hierarchy). And user doesn't have an access to "code" of error.
next prev parent reply other threads:[~2020-04-16 9:18 UTC|newest] Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-10 8:10 [Tarantool-patches] [PATCH v2 0/5] Extending error functionality Leonid Vasiliev 2020-04-10 8:10 ` [Tarantool-patches] [PATCH v2 1/5] error: Add a Lua backtrace to error Leonid Vasiliev 2020-04-14 1:11 ` Vladislav Shpilevoy 2020-04-15 9:25 ` lvasiliev 2020-04-16 0:00 ` Vladislav Shpilevoy 2020-04-16 1:11 ` Alexander Turenko 2020-04-16 8:58 ` lvasiliev 2020-04-16 9:30 ` Alexander Turenko 2020-04-16 12:27 ` lvasiliev 2020-04-16 12:45 ` Alexander Turenko 2020-04-16 17:48 ` lvasiliev 2020-04-16 8:40 ` lvasiliev 2020-04-16 9:04 ` lvasiliev 2020-04-10 8:10 ` [Tarantool-patches] [PATCH v2 2/5] error: Add the custom error type Leonid Vasiliev 2020-04-14 1:11 ` Vladislav Shpilevoy 2020-04-15 9:25 ` lvasiliev 2020-04-16 0:02 ` Vladislav Shpilevoy 2020-04-16 9:18 ` lvasiliev [this message] 2020-04-16 21:03 ` Vladislav Shpilevoy 2020-04-10 8:10 ` [Tarantool-patches] [PATCH v2 3/5] error: Increase the number of fields transmitted through IPROTO Leonid Vasiliev 2020-04-14 1:12 ` Vladislav Shpilevoy 2020-04-15 9:25 ` lvasiliev 2020-04-16 0:02 ` Vladislav Shpilevoy 2020-04-10 8:10 ` [Tarantool-patches] [PATCH v2 4/5] iproto: Add session settings for IPROTO Leonid Vasiliev 2020-04-14 1:12 ` Vladislav Shpilevoy 2020-04-15 9:26 ` lvasiliev 2020-04-16 0:06 ` Vladislav Shpilevoy 2020-04-16 9:36 ` lvasiliev 2020-04-16 21:04 ` Vladislav Shpilevoy 2020-04-10 8:10 ` [Tarantool-patches] [PATCH v2 5/5] iproto: Update error MsgPack encoding Leonid Vasiliev 2020-04-14 1:12 ` Vladislav Shpilevoy 2020-04-15 9:25 ` lvasiliev 2020-04-16 0:11 ` Vladislav Shpilevoy 2020-04-16 10:04 ` lvasiliev 2020-04-16 21:06 ` Vladislav Shpilevoy 2020-04-14 1:10 ` [Tarantool-patches] [PATCH v2 0/5] Extending error functionality Vladislav Shpilevoy 2020-04-15 9:48 ` lvasiliev
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=428aeafc-58b5-899d-b62e-bf08853d3366@tarantool.org \ --to=lvasiliev@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 2/5] error: Add the custom error type' \ /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