aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/surface
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-02-01 08:28:40 -0800
committerGravatar Craig Tiller <ctiller@google.com>2017-02-01 08:28:40 -0800
commitf4484cdbab0aab69417954f819d8f9e8c3d1718a (patch)
tree95fa3f644762151c4a23ea1e0fc9f149a01b7a47 /src/core/lib/surface
parent459e10d80e09a5c8e88dc10ff703358b5d3ee57b (diff)
Dont crash on API errors
Diffstat (limited to 'src/core/lib/surface')
-rw-r--r--src/core/lib/surface/call.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c
index 5519a1ec7e..27097faaa6 100644
--- a/src/core/lib/surface/call.c
+++ b/src/core/lib/surface/call.c
@@ -242,10 +242,18 @@ static void post_batch_completion(grpc_exec_ctx *exec_ctx, batch_control *bctl);
static void add_batch_error(grpc_exec_ctx *exec_ctx, batch_control *bctl,
grpc_error *error);
+static void add_init_error(grpc_error **composite, grpc_error *new) {
+ if (new == GRPC_ERROR_NONE) return;
+ if (*composite == GRPC_ERROR_NONE)
+ *composite = GRPC_ERROR_CREATE("Call creation failed");
+ *composite = grpc_error_add_child(*composite, new);
+}
+
grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
const grpc_call_create_args *args,
grpc_call **out_call) {
size_t i, j;
+ grpc_error *error = GRPC_ERROR_NONE;
grpc_channel_stack *channel_stack =
grpc_channel_get_channel_stack(args->channel);
grpc_call *call;
@@ -308,8 +316,11 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
grpc_call_context_set(
call, GRPC_CONTEXT_TRACING,
args->parent_call->context[GRPC_CONTEXT_TRACING].value, NULL);
- } else {
- GPR_ASSERT(args->propagation_mask & GRPC_PROPAGATE_CENSUS_STATS_CONTEXT);
+ } else if (0 ==
+ (args->propagation_mask & GRPC_PROPAGATE_CENSUS_STATS_CONTEXT)) {
+ add_init_error(&error,
+ GRPC_ERROR_CREATE("Census tracing propagation requested "
+ "without Census context propagation"));
}
if (args->propagation_mask & GRPC_PROPAGATE_CANCELLATION) {
call->cancellation_is_inherited = 1;
@@ -332,10 +343,11 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
GRPC_CHANNEL_INTERNAL_REF(args->channel, "call");
/* initial refcount dropped by grpc_call_destroy */
- grpc_error *error = grpc_call_stack_init(
- exec_ctx, channel_stack, 1, destroy_call, call, call->context,
- args->server_transport_data, path, call->start_time, send_deadline,
- CALL_STACK_FROM_CALL(call));
+ add_init_error(&error, grpc_call_stack_init(exec_ctx, channel_stack, 1,
+ destroy_call, call, call->context,
+ args->server_transport_data, path,
+ call->start_time, send_deadline,
+ CALL_STACK_FROM_CALL(call)));
if (error != GRPC_ERROR_NONE) {
cancel_with_error(exec_ctx, call, GRPC_ERROR_REF(error));
}