translate grpc errors to RPCError

This commit is contained in:
Victor Shyba 2021-08-13 17:42:56 -03:00 committed by Victor Shyba
parent a799503c97
commit 270192486a
2 changed files with 5 additions and 2 deletions

View file

@ -480,7 +480,10 @@ class Network:
async def new_claim_search(self, server, **kwargs):
async with grpc.aio.insecure_channel(server) as channel:
stub = hub_pb2_grpc.HubStub(channel)
response = await stub.Search(SearchRequest(**kwargs))
try:
response = await stub.Search(SearchRequest(**kwargs))
except grpc.aio.AioRpcError as error:
raise RPCError(error.code(), error.details())
return response
async def sum_supports(self, server, **kwargs):

View file

@ -205,4 +205,4 @@ class TestStress(CommandTestCase):
await self.stream_create()
with self.assertRaises(RPCError) as err:
await self.claim_search(not_channel_ids=[("%040x" % i) for i in range(8196)])
self.assertEqual(err.exception.message, 'not_channel_ids cant be set for more than 2048 items.')
self.assertEqual(err.exception.message, 'not_channel_ids cant have more than 2048 items.')