[Tarantool-patches] [PATCH 7/7] iproto: support error stacked diagnostic area

Nikita Pettik korablev at tarantool.org
Wed Mar 25 04:38:06 MSK 2020


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


More information about the Tarantool-patches mailing list