aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/lib/channel/channel_stack.c7
-rw-r--r--src/core/lib/iomgr/error.c6
-rw-r--r--src/core/lib/iomgr/error.h3
-rw-r--r--src/core/lib/surface/call.c10
4 files changed, 17 insertions, 9 deletions
diff --git a/src/core/lib/channel/channel_stack.c b/src/core/lib/channel/channel_stack.c
index 0613f94c29..715f631625 100644
--- a/src/core/lib/channel/channel_stack.c
+++ b/src/core/lib/channel/channel_stack.c
@@ -179,6 +179,7 @@ grpc_error* grpc_call_stack_init(grpc_exec_ctx *exec_ctx,
ROUND_UP_TO_ALIGNMENT_SIZE(count * sizeof(grpc_call_element));
/* init per-filter data */
+ grpc_error* first_error = GRPC_ERROR_NONE;
for (i = 0; i < count; i++) {
args.call_stack = call_stack;
args.server_transport_data = transport_server_data;
@@ -188,12 +189,12 @@ grpc_error* grpc_call_stack_init(grpc_exec_ctx *exec_ctx,
call_elems[i].call_data = user_data;
grpc_error* error = call_elems[i].filter->init_call_elem(
exec_ctx, &call_elems[i], &args);
- if (error != GRPC_ERROR_NONE)
- return error;
+ if (error != GRPC_ERROR_NONE && first_error == GRPC_ERROR_NONE)
+ first_error = error;
user_data +=
ROUND_UP_TO_ALIGNMENT_SIZE(call_elems[i].filter->sizeof_call_data);
}
- return GRPC_ERROR_NONE;
+ return first_error;
}
void grpc_call_stack_set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
diff --git a/src/core/lib/iomgr/error.c b/src/core/lib/iomgr/error.c
index 540fb4fa7e..1b15963e57 100644
--- a/src/core/lib/iomgr/error.c
+++ b/src/core/lib/iomgr/error.c
@@ -286,6 +286,12 @@ grpc_error *grpc_error_set_str(grpc_error *src, grpc_error_strs which,
return new;
}
+const char *grpc_error_get_str(grpc_error *error, grpc_error_strs which) {
+ void *s = NULL;
+ gpr_avl_maybe_get(error->strs, (void *)(uintptr_t)which, &s);
+ return s;
+}
+
grpc_error *grpc_error_add_child(grpc_error *src, grpc_error *child) {
grpc_error *new = copy_error_and_unref(src);
new->errs = gpr_avl_add(new->errs, (void *)(new->next_err++), child);
diff --git a/src/core/lib/iomgr/error.h b/src/core/lib/iomgr/error.h
index 69cdf3028e..4bff591fe3 100644
--- a/src/core/lib/iomgr/error.h
+++ b/src/core/lib/iomgr/error.h
@@ -169,6 +169,9 @@ grpc_error *grpc_error_set_time(grpc_error *src, grpc_error_times which,
gpr_timespec value);
grpc_error *grpc_error_set_str(grpc_error *src, grpc_error_strs which,
const char *value);
+/// Returns NULL if the specified string is not set.
+/// Caller does NOT own return value.
+const char *grpc_error_get_str(grpc_error *error, grpc_error_strs which);
/// Add a child error: an error that is believed to have contributed to this
/// error occurring. Allows root causing high level errors from lower level
/// errors that contributed to them.
diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c
index 2e89393815..d68afff39f 100644
--- a/src/core/lib/surface/call.c
+++ b/src/core/lib/surface/call.c
@@ -270,12 +270,10 @@ grpc_call *grpc_call_create(
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);
+ const char* error_str = grpc_error_get_str(error,
+ GRPC_ERROR_STR_DESCRIPTION);
+ close_with_status(&exec_ctx, call, status,
+ error_str == NULL ? "unknown error" : error_str);
grpc_error_unref(error);
}
if (cq != NULL) {