From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp3.mail.ru (smtp3.mail.ru [94.100.179.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id CCD29441841 for ; Wed, 25 Mar 2020 04:38:06 +0300 (MSK) Date: Wed, 25 Mar 2020 01:38:06 +0000 From: Nikita Pettik Message-ID: <20200325013806.GC30598@tarantool.org> References: <98b175140b1bf2e2f9d3285ca281008b9d7b6c11.1582119629.git.korablev@tarantool.org> <2a5f311b-54cd-9b82-af60-1b95397ed687@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <2a5f311b-54cd-9b82-af60-1b95397ed687@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH 7/7] iproto: support error stacked diagnostic area List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org On 23 Feb 18:43, Vladislav Shpilevoy wrote: > Thanks for the patch! > > > diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua > > index b4811edfa..9a619e3d4 100644 > > --- a/src/box/lua/net_box.lua > > +++ b/src/box/lua/net_box.lua > > @@ -277,8 +280,24 @@ local function create_transport(host, port, user, password, callback, > > -- > > function request_index:result() > > if self.errno then > > - return nil, box.error.new({code = self.errno, > > - reason = self.response}) > > + if type(self.response) == 'table' then > > + -- Decode and fill in error stack. > > + local prev = nil > > + for i = #self.response, 1, -1 do > > 4. Why do you start from the end? Seems like you could easily > do the same with the direct iteration. Your way is not worse, > but it raises unnecessary questions. Hm, it's like stack restoration from top to bottom. On the contrary it seems to be more rational to start iterating from the top (IMHO). > > + local error = self.response[i] > > + local code = error[IPROTO_ERROR_CODE] > > + local msg = error[IPROTO_ERROR_MESSAGE] > > + assert(type(code) == 'number') > > + assert(type(msg) == 'string') > > + local new_err = box.error.new({code = code, reason = msg}) > > + new_err:set_prev(prev) > > + prev = new_err > > + end > > + return nil, prev > > + else > > + return nil, box.error.new({code = self.errno, > > + reason = self.response}) > > + end > > elseif not self.id then > > return self.response > > elseif not worker_fiber then