aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/iomgr/error.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-05-06 17:12:37 -0700
committerGravatar Craig Tiller <ctiller@google.com>2016-05-06 17:12:37 -0700
commit4f1d0f337b15748d171ec21dddba1f6d80e94778 (patch)
tree255d62f007305913e744efc72ac429583dc166f1 /src/core/lib/iomgr/error.c
parent80384bd2e389b38f594f74055051e46d62509bf3 (diff)
Error reporting progress
Diffstat (limited to 'src/core/lib/iomgr/error.c')
-rw-r--r--src/core/lib/iomgr/error.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/core/lib/iomgr/error.c b/src/core/lib/iomgr/error.c
index d5587a4194..bc50d6870f 100644
--- a/src/core/lib/iomgr/error.c
+++ b/src/core/lib/iomgr/error.c
@@ -469,3 +469,13 @@ grpc_error *grpc_os_error(const char *file, int line, int err,
GRPC_ERROR_STR_OS_ERROR, strerror(err)),
GRPC_ERROR_STR_SYSCALL, call_name);
}
+
+bool grpc_log_if_error(const char *what, grpc_error *error, const char *file,
+ int line) {
+ if (error == GRPC_ERROR_NONE) return true;
+ const char *msg = grpc_error_string(error);
+ gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "%s: %s", what, msg);
+ grpc_error_free_string(msg);
+ GRPC_ERROR_UNREF(error);
+ return false;
+}