Skip to content

Commit 2ab64a2

Browse files
Change conversion of box.error to string in error message assertions
Currently, error message assertions convert `box.error` to string using `tostring`. `box.error`'s `__tostring` metamethod is currently equivalent to the `message` field of `box.error`. In scope of tarantool/tarantool#9105, we are going to increase the verbosity of `box.error` `__tostring` metamethod, and it will no longer be convenient for testing the error message. Let's replace `tostring(error)` with `error.message` usag to retain the old behaviour. Needed for tarantool/tarantool#9105
1 parent f8a1c10 commit 2ab64a2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

luatest/assertions.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ local function _assert_error_msg_equals(stripFileAndLine, expectedMsg, func, ...
468468
end
469469
if type(expectedMsg) == "string" and type(error_msg) ~= "string" then
470470
-- table are converted to string automatically
471-
error_msg = tostring(error_msg)
471+
error_msg = error_msg.message
472472
end
473473
local differ = false
474474
if stripFileAndLine then
@@ -533,7 +533,7 @@ function M.assert_error_msg_contains(expected_partial, fn, ...)
533533
failure(failure_message, nil, 2)
534534
end
535535
if type(error_msg) ~= "string" then
536-
error_msg = tostring(error_msg)
536+
error_msg = error_msg.message
537537
end
538538
if not string.find(error_msg, expected_partial, nil, true) then
539539
error_msg, expected_partial = prettystr_pairs(error_msg, expected_partial)
@@ -555,7 +555,7 @@ function M.assert_error_msg_matches(pattern, fn, ...)
555555
failure(failure_message, nil, 2)
556556
end
557557
if type(error_msg) ~= "string" then
558-
error_msg = tostring(error_msg)
558+
error_msg = error_msg.message
559559
end
560560
if not str_match(error_msg, pattern) then
561561
pattern, error_msg = prettystr_pairs(pattern, error_msg)

0 commit comments

Comments
 (0)