include/grpcpp/impl/codegen/status.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPCPP_IMPL_CODEGEN_STATUS_H
20 #define GRPCPP_IMPL_CODEGEN_STATUS_H
21 
22 // IWYU pragma: private, include <grpcpp/support/status.h>
23 
25 
29 
30 namespace grpc {
31 
36  public:
38  Status() : code_(StatusCode::OK) {
39  // Static assertions to make sure that the C++ API value correctly
40  // maps to the core surface API value
41  static_assert(StatusCode::OK == static_cast<StatusCode>(GRPC_STATUS_OK),
42  "Mismatched status code");
43  static_assert(
45  "Mismatched status code");
46  static_assert(
48  "Mismatched status code");
49  static_assert(StatusCode::INVALID_ARGUMENT ==
51  "Mismatched status code");
52  static_assert(StatusCode::DEADLINE_EXCEEDED ==
54  "Mismatched status code");
55  static_assert(
57  "Mismatched status code");
58  static_assert(StatusCode::ALREADY_EXISTS ==
60  "Mismatched status code");
61  static_assert(StatusCode::PERMISSION_DENIED ==
63  "Mismatched status code");
64  static_assert(StatusCode::UNAUTHENTICATED ==
66  "Mismatched status code");
67  static_assert(StatusCode::RESOURCE_EXHAUSTED ==
69  "Mismatched status code");
70  static_assert(StatusCode::FAILED_PRECONDITION ==
72  "Mismatched status code");
73  static_assert(
75  "Mismatched status code");
76  static_assert(StatusCode::OUT_OF_RANGE ==
78  "Mismatched status code");
79  static_assert(StatusCode::UNIMPLEMENTED ==
81  "Mismatched status code");
82  static_assert(
84  "Mismatched status code");
85  static_assert(StatusCode::UNAVAILABLE ==
86  static_cast<StatusCode>(GRPC_STATUS_UNAVAILABLE),
87  "Mismatched status code");
88  static_assert(
90  "Mismatched status code");
91  }
92 
99  Status(StatusCode code, const std::string& error_message)
100  : code_(code), error_message_(error_message) {}
101 
105  Status(StatusCode code, const std::string& error_message,
106  const std::string& error_details)
107  : code_(code),
108  error_message_(error_message),
109  binary_error_details_(error_details) {}
110 
111  // Pre-defined special status objects.
113  static const Status& OK;
115  static const Status& CANCELLED;
116 
118  StatusCode error_code() const { return code_; }
122  // Usually it contains a serialized google.rpc.Status proto.
123  std::string error_details() const { return binary_error_details_; }
124 
126  bool ok() const { return code_ == StatusCode::OK; }
127 
128  // Ignores any errors. This method does nothing except potentially suppress
129  // complaints from any tools that are checking that errors are not dropped on
130  // the floor.
131  void IgnoreError() const {}
132 
133  private:
137 };
138 
139 } // namespace grpc
140 
141 #endif // GRPCPP_IMPL_CODEGEN_STATUS_H
grpc.StatusCode.ALREADY_EXISTS
tuple ALREADY_EXISTS
Definition: src/python/grpcio/grpc/__init__.py:267
GRPC_STATUS_UNAVAILABLE
@ GRPC_STATUS_UNAVAILABLE
Definition: include/grpc/impl/codegen/status.h:143
grpc::Status::CANCELLED
static const Status & CANCELLED
A CANCELLED pre-defined instance.
Definition: include/grpcpp/impl/codegen/status.h:115
GRPC_STATUS_UNAUTHENTICATED
@ GRPC_STATUS_UNAUTHENTICATED
Definition: include/grpc/impl/codegen/status.h:72
grpc
Definition: grpcpp/alarm.h:33
grpc::Status::ok
bool ok() const
Is the status OK?
Definition: include/grpcpp/impl/codegen/status.h:126
grpc::Status::Status
Status(StatusCode code, const std::string &error_message, const std::string &error_details)
Definition: include/grpcpp/impl/codegen/status.h:105
GRPC_STATUS_PERMISSION_DENIED
@ GRPC_STATUS_PERMISSION_DENIED
Definition: include/grpc/impl/codegen/status.h:68
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc.StatusCode.ABORTED
tuple ABORTED
Definition: src/python/grpcio/grpc/__init__.py:274
GRPC_STATUS_NOT_FOUND
@ GRPC_STATUS_NOT_FOUND
Definition: include/grpc/impl/codegen/status.h:56
GRPC_STATUS_CANCELLED
@ GRPC_STATUS_CANCELLED
Definition: include/grpc/impl/codegen/status.h:33
GRPC_STATUS_DEADLINE_EXCEEDED
@ GRPC_STATUS_DEADLINE_EXCEEDED
Definition: include/grpc/impl/codegen/status.h:53
grpc::Status::Status
Status(StatusCode code, const std::string &error_message)
Definition: include/grpcpp/impl/codegen/status.h:99
GRPC_STATUS_INVALID_ARGUMENT
@ GRPC_STATUS_INVALID_ARGUMENT
Definition: include/grpc/impl/codegen/status.h:46
GRPC_STATUS_RESOURCE_EXHAUSTED
@ GRPC_STATUS_RESOURCE_EXHAUSTED
Definition: include/grpc/impl/codegen/status.h:76
status_code_enum.h
config.h
grpc.StatusCode.FAILED_PRECONDITION
tuple FAILED_PRECONDITION
Definition: src/python/grpcio/grpc/__init__.py:272
error_message_
const std::string error_message_
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:451
grpc.StatusCode.RESOURCE_EXHAUSTED
tuple RESOURCE_EXHAUSTED
Definition: src/python/grpcio/grpc/__init__.py:270
GRPC_STATUS_OK
@ GRPC_STATUS_OK
Definition: include/grpc/impl/codegen/status.h:30
grpc.StatusCode.OK
tuple OK
Definition: src/python/grpcio/grpc/__init__.py:260
grpc::Status::error_message
std::string error_message() const
Return the instance's error message.
Definition: include/grpcpp/impl/codegen/status.h:120
grpc.StatusCode
Definition: src/python/grpcio/grpc/__init__.py:232
grpc::OK
@ OK
Not an error; returned on success.
Definition: grpcpp/impl/codegen/status_code_enum.h:28
grpc.StatusCode.UNKNOWN
tuple UNKNOWN
Definition: src/python/grpcio/grpc/__init__.py:262
grpc.StatusCode.PERMISSION_DENIED
tuple PERMISSION_DENIED
Definition: src/python/grpcio/grpc/__init__.py:268
grpc::Status::error_message_
std::string error_message_
Definition: include/grpcpp/impl/codegen/status.h:135
grpc.StatusCode.NOT_FOUND
tuple NOT_FOUND
Definition: src/python/grpcio/grpc/__init__.py:266
grpc.StatusCode.DATA_LOSS
tuple DATA_LOSS
Definition: src/python/grpcio/grpc/__init__.py:279
GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING
#define GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING
Definition: impl/codegen/port_platform.h:598
grpc::Status::OK
static const Status & OK
An OK pre-defined instance.
Definition: include/grpcpp/impl/codegen/status.h:113
grpc.StatusCode.UNAUTHENTICATED
tuple UNAUTHENTICATED
Definition: src/python/grpcio/grpc/__init__.py:280
GRPC_STATUS_ALREADY_EXISTS
@ GRPC_STATUS_ALREADY_EXISTS
Definition: include/grpc/impl/codegen/status.h:60
GRPC_STATUS_DATA_LOSS
@ GRPC_STATUS_DATA_LOSS
Definition: include/grpc/impl/codegen/status.h:146
grpc.StatusCode.UNIMPLEMENTED
tuple UNIMPLEMENTED
Definition: src/python/grpcio/grpc/__init__.py:276
status.h
GRPC_STATUS_OUT_OF_RANGE
@ GRPC_STATUS_OUT_OF_RANGE
Definition: include/grpc/impl/codegen/status.h:121
GRPC_STATUS_ABORTED
@ GRPC_STATUS_ABORTED
Definition: include/grpc/impl/codegen/status.h:104
port_platform.h
grpc::Status::Status
Status()
Construct an OK instance.
Definition: include/grpcpp/impl/codegen/status.h:38
grpc.StatusCode.INVALID_ARGUMENT
tuple INVALID_ARGUMENT
Definition: src/python/grpcio/grpc/__init__.py:263
grpc::Status::code_
StatusCode code_
Definition: include/grpcpp/impl/codegen/status.h:134
grpc::Status
Definition: include/grpcpp/impl/codegen/status.h:35
grpc::Status::binary_error_details_
std::string binary_error_details_
Definition: include/grpcpp/impl/codegen/status.h:136
grpc::Status::error_details
std::string error_details() const
Return the (binary) error details.
Definition: include/grpcpp/impl/codegen/status.h:123
grpc.StatusCode.UNAVAILABLE
tuple UNAVAILABLE
Definition: src/python/grpcio/grpc/__init__.py:278
GRPC_STATUS_UNIMPLEMENTED
@ GRPC_STATUS_UNIMPLEMENTED
Definition: include/grpc/impl/codegen/status.h:124
GRPC_STATUS_FAILED_PRECONDITION
@ GRPC_STATUS_FAILED_PRECONDITION
Definition: include/grpc/impl/codegen/status.h:97
grpc.StatusCode.CANCELLED
tuple CANCELLED
Definition: src/python/grpcio/grpc/__init__.py:261
GRPC_STATUS_INTERNAL
@ GRPC_STATUS_INTERNAL
Definition: include/grpc/impl/codegen/status.h:129
grpc::Status::error_code
StatusCode error_code() const
Return the instance's error code.
Definition: include/grpcpp/impl/codegen/status.h:118
grpc::Status::IgnoreError
void IgnoreError() const
Definition: include/grpcpp/impl/codegen/status.h:131
code
Definition: bloaty/third_party/zlib/contrib/infback9/inftree9.h:24
grpc.StatusCode.DEADLINE_EXCEEDED
tuple DEADLINE_EXCEEDED
Definition: src/python/grpcio/grpc/__init__.py:264
grpc.StatusCode.INTERNAL
tuple INTERNAL
Definition: src/python/grpcio/grpc/__init__.py:277
grpc.StatusCode.OUT_OF_RANGE
tuple OUT_OF_RANGE
Definition: src/python/grpcio/grpc/__init__.py:275
GRPC_STATUS_UNKNOWN
@ GRPC_STATUS_UNKNOWN
Definition: include/grpc/impl/codegen/status.h:40


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:22