box/error: don't set error created via box.error.new to diag
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... '''
Showing
- src/box/error.cc 16 additions, 0 deletionssrc/box/error.cc
- src/box/error.h 8 additions, 0 deletionssrc/box/error.h
- src/box/lua/error.cc 32 additions, 24 deletionssrc/box/lua/error.cc
- test/box/error.result 31 additions, 1 deletiontest/box/error.result
- test/box/error.test.lua 16 additions, 0 deletionstest/box/error.test.lua
Loading
Please register or sign in to comment