From 9f97cca37b21fbac12d840fa2337f1fba251e77c Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 23 Jun 2016 10:47:05 -0700 Subject: Fix error handling in grpc_call_create(). --- src/core/lib/surface/call.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c index d64ca64a15..2e89393815 100644 --- a/src/core/lib/surface/call.c +++ b/src/core/lib/surface/call.c @@ -266,8 +266,18 @@ grpc_call *grpc_call_create( destroy_call, call, call->context, server_transport_data, CALL_STACK_FROM_CALL(call)); -// FIXME: handle error (probably requires changing this function's API) -GPR_ASSERT(error == GRPC_ERROR_NONE); + if (error != GRPC_ERROR_NONE) { + intptr_t status; + if (!grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, &status)) + status = GRPC_STATUS_UNKNOWN; + const char* error_string = grpc_error_string(error); + received_status* status_struct = &call->status[STATUS_FROM_CORE]; + status_struct->is_set = true; + status_struct->code = status; + status_struct->details = grpc_mdstr_from_string(error_string); + grpc_error_free_string(error_string); + grpc_error_unref(error); + } if (cq != NULL) { GPR_ASSERT( pollset_set_alternative == NULL && -- cgit v1.2.3