Get the debug_error_string in a simpler fashion

* Use the public method in ``AioRpcStatus``
* Keep everything encapsulated inside the function that creates the
error.
pull/21919/head
Mariano Anaya 5 years ago
parent 583712704a
commit 1df63bf35b
  1. 11
      src/python/grpcio/grpc/experimental/aio/_call.py

@ -142,14 +142,13 @@ class AioRpcError(grpc.RpcError):
def _create_rpc_error(initial_metadata: Optional[MetadataType],
status: cygrpc.AioRpcStatus,
debug_error_string: Optional[str] = None) -> AioRpcError:
status: cygrpc.AioRpcStatus) -> AioRpcError:
return AioRpcError(
_common.CYGRPC_STATUS_CODE_TO_STATUS_CODE[status.code()],
status.details(),
initial_metadata,
status.trailing_metadata(),
debug_error_string,
status.debug_error_string(),
)
@ -275,12 +274,8 @@ class _UnaryResponseMixin(Call):
if self._cython_call.is_locally_cancelled():
raise asyncio.CancelledError()
else:
call_status = self._cython_call._status
debug_error_string = None
if call_status is not None:
debug_error_string = call_status._debug_error_string
raise _create_rpc_error(self._cython_call._initial_metadata,
call_status, debug_error_string)
self._cython_call._status)
else:
return response

Loading…
Cancel
Save