diff options
author | 2016-09-06 14:05:53 -0700 | |
---|---|---|
committer | 2016-09-09 09:37:33 -0700 | |
commit | d558149a5e6c4a63bc4e6d552d2c492589cccf2d (patch) | |
tree | 900a6fd0e0f238649c8af722d8e777383480cdc4 /include/grpc++/impl | |
parent | 74c92f62d9e8d2be9f74b5fd349b6a5c519cf82f (diff) |
Add a helper to get canonical code from status
Diffstat (limited to 'include/grpc++/impl')
-rw-r--r-- | include/grpc++/impl/codegen/call.h | 3 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/status_helper.h | 47 |
2 files changed, 49 insertions, 1 deletions
diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h index df225d362b..eae03e7b8e 100644 --- a/include/grpc++/impl/codegen/call.h +++ b/include/grpc++/impl/codegen/call.h @@ -46,6 +46,7 @@ #include <grpc++/impl/codegen/core_codegen_interface.h> #include <grpc++/impl/codegen/serialization_traits.h> #include <grpc++/impl/codegen/status.h> +#include <grpc++/impl/codegen/status_helper.h> #include <grpc++/impl/codegen/string_ref.h> #include <grpc/impl/codegen/alloc.h> @@ -434,7 +435,7 @@ class CallOpServerSendStatus { trailing_metadata_count_ = trailing_metadata.size(); trailing_metadata_ = FillMetadataArray(trailing_metadata); send_status_available_ = true; - send_status_code_ = static_cast<grpc_status_code>(status.error_code()); + send_status_code_ = static_cast<grpc_status_code>(GetCanonicalCode(status)); send_status_details_ = status.error_message(); } diff --git a/include/grpc++/impl/codegen/status_helper.h b/include/grpc++/impl/codegen/status_helper.h new file mode 100644 index 0000000000..bfe45d9e5b --- /dev/null +++ b/include/grpc++/impl/codegen/status_helper.h @@ -0,0 +1,47 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPCXX_IMPL_CODEGEN_STATUS_HELPER_H +#define GRPCXX_IMPL_CODEGEN_STATUS_HELPER_H + +#include <grpc++/impl/codegen/status.h> + +namespace grpc { + +inline StatusCode GetCanonicalCode(const Status& status) { + return status.error_code(); +} + +} // namespace grpc + +#endif // GRPCXX_IMPL_CODEGEN_STATUS_HELPER_H |