Skip to content
Snippets Groups Projects
  • Nikita Pettik's avatar
    eaa86088
    box/error: don't set error created via box.error.new to diag · eaa86088
    Nikita Pettik authored
    To achieve this let's refactor luaT_error_create() to return error
    object instead of setting it via box_error_set().
    luaT_error_create() is used both to handle box.error() and
    box.error.new() invocations, and box.error() is still expected to set
    error to diagnostic area. So, luaT_error_call() which implements
    box.error() processing at the end calls diag_set_error().
    It is worth mentioning that net.box module relied on the fact that
    box.error.new() set error to diagnostic area: otherwise request errors
    don't get to diagnostic area on client side.
    
    Needed for #1148
    Closes #4778
    
    @TarantoolBot document
    Title: Don't promote error created via box.error.new to diagnostic area
    
    Now box.error.new() only creates error object, but doesn't set it to
    Tarantool's diagnostic area:
    ```
    box.error.clear()
    e = box.error.new({code = 111, reason = "cause"})
    assert(box.error.last() == nil)
    ---
    - true
    ...
    ```
    To set error in diagnostic area explicitly box.error.set() has been
    introduced. It accepts error object which is set as last system error
    (i.e. becomes available via box.error.last()).
    Finally, box.error.new() does not longer accept error object as an
    argument (this was undocumented feature).
    Note that patch does not affect box.error(), which still pushes error to
    diagnostic area. This fact is reflected in docs:
    '''
    Emulate a request error, with text based on one of the pre-defined
    Tarantool errors...
    '''
    eaa86088
    History
    box/error: don't set error created via box.error.new to diag
    Nikita Pettik authored
    To achieve this let's refactor luaT_error_create() to return error
    object instead of setting it via box_error_set().
    luaT_error_create() is used both to handle box.error() and
    box.error.new() invocations, and box.error() is still expected to set
    error to diagnostic area. So, luaT_error_call() which implements
    box.error() processing at the end calls diag_set_error().
    It is worth mentioning that net.box module relied on the fact that
    box.error.new() set error to diagnostic area: otherwise request errors
    don't get to diagnostic area on client side.
    
    Needed for #1148
    Closes #4778
    
    @TarantoolBot document
    Title: Don't promote error created via box.error.new to diagnostic area
    
    Now box.error.new() only creates error object, but doesn't set it to
    Tarantool's diagnostic area:
    ```
    box.error.clear()
    e = box.error.new({code = 111, reason = "cause"})
    assert(box.error.last() == nil)
    ---
    - true
    ...
    ```
    To set error in diagnostic area explicitly box.error.set() has been
    introduced. It accepts error object which is set as last system error
    (i.e. becomes available via box.error.last()).
    Finally, box.error.new() does not longer accept error object as an
    argument (this was undocumented feature).
    Note that patch does not affect box.error(), which still pushes error to
    diagnostic area. This fact is reflected in docs:
    '''
    Emulate a request error, with text based on one of the pre-defined
    Tarantool errors...
    '''