From 2e7d957a63c9bcfe0235f8b5d55fd9a372a32ced Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Fri, 15 Apr 2016 17:29:57 -0700 Subject: Provide a function that converts grpc_call_error values into a string --- src/core/lib/surface/call.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/core') diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c index 6581bbd3d1..8deb3442de 100644 --- a/src/core/lib/surface/call.c +++ b/src/core/lib/surface/call.c @@ -1512,3 +1512,40 @@ grpc_compression_algorithm grpc_call_compression_for_level( gpr_mu_unlock(&call->mu); return grpc_compression_algorithm_for_level(level, accepted_encodings); } + +const char *grpc_call_error_to_string(grpc_call_error error) { + switch (error) { + case GRPC_CALL_ERROR: + return "GRPC_CALL_ERROR"; + case GRPC_CALL_ERROR_ALREADY_ACCEPTED: + return "GRPC_CALL_ERROR_ALREADY_ACCEPTED"; + case GRPC_CALL_ERROR_ALREADY_FINISHED: + return "GRPC_CALL_ERROR_ALREADY_FINISHED"; + case GRPC_CALL_ERROR_ALREADY_INVOKED: + return "GRPC_CALL_ERROR_ALREADY_INVOKED"; + case GRPC_CALL_ERROR_BATCH_TOO_BIG: + return "GRPC_CALL_ERROR_BATCH_TOO_BIG"; + case GRPC_CALL_ERROR_INVALID_FLAGS: + return "GRPC_CALL_ERROR_INVALID_FLAGS"; + case GRPC_CALL_ERROR_INVALID_MESSAGE: + return "GRPC_CALL_ERROR_INVALID_MESSAGE"; + case GRPC_CALL_ERROR_INVALID_METADATA: + return "GRPC_CALL_ERROR_INVALID_METADATA"; + case GRPC_CALL_ERROR_NOT_INVOKED: + return "GRPC_CALL_ERROR_NOT_INVOKED"; + case GRPC_CALL_ERROR_NOT_ON_CLIENT: + return "GRPC_CALL_ERROR_NOT_ON_CLIENT"; + case GRPC_CALL_ERROR_NOT_ON_SERVER: + return "GRPC_CALL_ERROR_NOT_ON_SERVER"; + case GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE: + return "GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE"; + case GRPC_CALL_ERROR_PAYLOAD_TYPE_MISMATCH: + return "GRPC_CALL_ERROR_PAYLOAD_TYPE_MISMATCH"; + case GRPC_CALL_ERROR_TOO_MANY_OPERATIONS: + return "GRPC_CALL_ERROR_TOO_MANY_OPERATIONS"; + case GRPC_CALL_OK: + return "GRPC_CALL_OK"; + default: + return "GRPC_CALL_ERROR_UNKNOW"; + } +} -- cgit v1.2.3 From f02bada24fc67bc1a6e93108ce466d969a04afd1 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Tue, 19 Apr 2016 14:12:27 -0700 Subject: remove defaut case in grpc_call_error_to_string --- src/core/lib/surface/call.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c index 8deb3442de..02bc019332 100644 --- a/src/core/lib/surface/call.c +++ b/src/core/lib/surface/call.c @@ -1545,7 +1545,6 @@ const char *grpc_call_error_to_string(grpc_call_error error) { return "GRPC_CALL_ERROR_TOO_MANY_OPERATIONS"; case GRPC_CALL_OK: return "GRPC_CALL_OK"; - default: - return "GRPC_CALL_ERROR_UNKNOW"; } + GPR_UNREACHABLE_CODE(return "GRPC_CALL_ERROR_UNKNOW"); } -- cgit v1.2.3