From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 13C5E25DEF for ; Thu, 8 Aug 2019 19:33:44 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jLWcbejC9BQN for ; Thu, 8 Aug 2019 19:33:44 -0400 (EDT) Received: from smtp48.i.mail.ru (smtp48.i.mail.ru [94.100.177.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id C42C025D8B for ; Thu, 8 Aug 2019 19:33:43 -0400 (EDT) Date: Fri, 9 Aug 2019 02:33:27 +0300 From: Alexander Turenko Subject: [tarantool-patches] Re: [PATCH v1 3/3] box: extend ffi error object API Message-ID: <20190808233327.sjm76nwf2qhxd4io@tkn_work_nb> References: <47d9072e60bdc563c7466a4e51db1a61bc71a610.1564657285.git.kshcherbatov@tarantool.org> <55d56797-f937-4088-fdba-7d9dfef51ae6@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <55d56797-f937-4088-fdba-7d9dfef51ae6@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: Vladislav Shpilevoy Cc: tarantool-patches@freelists.org, Kirill Shcherbatov , kostja@tarantool.org > > +box_error_unwrap(box_error_t *error) > > +{ > > + struct error *reason = error->reason; > > + assert(reason != NULL); > > + diag_set_error(diag_get(), reason); > > + error_unref(reason); > > + error->reason = NULL; > > + return reason; > > 7. Unwrap does not allow to unwrap a leaf error. > But there is no API to determine if the error is > leaf. So a user can't determine when to stop calling > unwrap. > > I am talking about C public API which you have changed > here. A user can't check error->reason != NULL before > calling box_error_unwrap. > > Moreover, it is inconsistent with Lua version. Lets > better return the argument when error->reason == NULL > in box_error_unwrap. Then a user of the C API would > just unwrap the stack until box_error_unwrap(e) == e. > Also it simplifies Lua version implementation. Why not just return NULL when there is no a reason? It seems to be more logical for me.