Improve error message by including the error code

pull/22343/head
Mariano Anaya 5 years ago committed by Lidi Zheng
parent 4ec09a0a26
commit 764be7ed92
  1. 2
      src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pyx.pxi
  2. 9
      src/python/grpcio_tests/tests_aio/unit/_test_server.py

@ -125,7 +125,7 @@ cdef class _AioCall(GrpcCallWrapper):
if credentials is not None: if credentials is not None:
set_credentials_error = grpc_call_set_credentials(self.call, credentials.c()) set_credentials_error = grpc_call_set_credentials(self.call, credentials.c())
if set_credentials_error != GRPC_CALL_OK: if set_credentials_error != GRPC_CALL_OK:
raise RuntimeError("Credentials couldn't have been set") raise RuntimeError(f"Credentials couldn't have been set: {set_credentials_error}")
grpc_slice_unref(method_slice) grpc_slice_unref(method_slice)

@ -24,6 +24,10 @@ from tests_aio.unit import _constants
_INITIAL_METADATA_KEY = "x-grpc-test-echo-initial" _INITIAL_METADATA_KEY = "x-grpc-test-echo-initial"
_TRAILING_METADATA_KEY = "x-grpc-test-echo-trailing-bin" _TRAILING_METADATA_KEY = "x-grpc-test-echo-trailing-bin"
_PRIVATE_KEY = resources.private_key()
_CERTIFICATE_CHAIN = resources.certificate_chain()
_TEST_ROOT_CERTIFICATES = resources.test_root_certificates()
_SERVER_CERTS = ((_PRIVATE_KEY, _CERTIFICATE_CHAIN),)
async def _maybe_echo_metadata(servicer_context): async def _maybe_echo_metadata(servicer_context):
@ -38,11 +42,6 @@ async def _maybe_echo_metadata(servicer_context):
invocation_metadata[_TRAILING_METADATA_KEY]) invocation_metadata[_TRAILING_METADATA_KEY])
servicer_context.set_trailing_metadata((trailing_metadatum,)) servicer_context.set_trailing_metadata((trailing_metadatum,))
_PRIVATE_KEY = resources.private_key()
_CERTIFICATE_CHAIN = resources.certificate_chain()
_TEST_ROOT_CERTIFICATES = resources.test_root_certificates()
_SERVER_CERTS = ((_PRIVATE_KEY, _CERTIFICATE_CHAIN),)
async def _maybe_echo_status(request: messages_pb2.SimpleRequest, async def _maybe_echo_status(request: messages_pb2.SimpleRequest,
servicer_context): servicer_context):

Loading…
Cancel
Save