Skip to content

Commit 45b5835

Browse files
a1div0vakhov
authored andcommitted
[CE-431] Fixed incorrect error display
Error text retrieval changed from `err.err` to `tostring(err)` based on the following reasons: 1. If `err` happens to be a string, the result will also be a string 2. If `err` is an instance of `vshard.error`, it has a `tostring` operator that converts the structure into a JSON string 3. If `err` is an instance of the generic `errors` module, it also provides a `tostring` method (cherry picked from commit cf7d963bea98a1f21a673531c88cec98dcaf58a1)
1 parent 419296e commit 45b5835

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111

1212
* `crud.schema` no longer returns system space `_gc_consumers` with Tarantool 3.2+.
1313
* Tests of `schema` with Tarantool 3.2+.
14+
* Fixed bad error handling for method `call.single`
1415

1516
## [1.5.2] - 20-05-24
1617

crud/common/call.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ function call.single(vshard_router, bucket_id, func_name, func_args, opts)
198198

199199
local replicaset, err = vshard_router:route(bucket_id)
200200
if err ~= nil then
201-
return nil, CallError:new("Failed to get router replicaset: %s", err.err)
201+
return nil, CallError:new("Failed to get router replicaset: %s", tostring(err))
202202
end
203203

204204
local timeout = opts.timeout or const.DEFAULT_VSHARD_CALL_TIMEOUT

test/integration/custom_bucket_id_test.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,3 +555,17 @@ pgroup.test_select = function(g)
555555
-- tuple is found
556556
t.assert_equals(#result.rows, 1)
557557
end
558+
559+
pgroup.test_non_existent_bucket_id = function(g)
560+
local _, err = g.router:call('crud.insert', {
561+
'customers', {1, box.NULL, 'Maria', 23}, {bucket_id = 999999}
562+
})
563+
t.assert_equals(type(err), 'table')
564+
t.assert_equals(err.class_name, 'InsertError')
565+
t.assert_str_contains(
566+
err.err,
567+
'Failed to call insert on storage-side: CallError: Failed to get router replicaset: '
568+
.. '{"bucket_id":999999,"code":9,"type":"ShardingError","message":"Bucket 999999 cannot'
569+
.. ' be found. Is rebalancing in progress?","name":"NO_ROUTE_TO_BUCKET"}'
570+
)
571+
end

0 commit comments

Comments
 (0)