grpc
include
grpcpp
support
grpcpp/support/error_details.h
Go to the documentation of this file.
1
/*
2
*
3
* Copyright 2017 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_SUPPORT_ERROR_DETAILS_H
20
#define GRPCPP_SUPPORT_ERROR_DETAILS_H
21
22
#include <
grpcpp/support/status.h
>
23
24
namespace
grpc
{
25
37
template
<
typename
T>
38
grpc::Status
ExtractErrorDetails
(
const
grpc::Status
&
from
,
T
*
to
) {
39
if
(
to
==
nullptr
) {
40
return
grpc::Status
(
grpc::StatusCode::FAILED_PRECONDITION
,
""
);
41
}
42
if
(!
to
->ParseFromString(
from
.error_details())) {
43
return
grpc::Status
(
grpc::StatusCode::INVALID_ARGUMENT
,
""
);
44
}
45
return
grpc::Status::OK
;
46
}
47
inline
grpc::Status
ExtractErrorDetails
(
const
grpc::Status
&, std::nullptr_t) {
48
return
grpc::Status
(
grpc::StatusCode::FAILED_PRECONDITION
,
""
);
49
}
50
60
template
<
typename
T>
61
grpc::Status
SetErrorDetails
(
const
T
&
from
,
grpc::Status
*
to
) {
62
if
(
to
==
nullptr
) {
63
return
grpc::Status
(
grpc::StatusCode::FAILED_PRECONDITION
,
""
);
64
}
65
grpc::StatusCode
code
=
grpc::StatusCode::UNKNOWN
;
66
if
(
from
.code() >=
grpc::StatusCode::OK
&&
67
from
.code() <=
grpc::StatusCode::UNAUTHENTICATED
) {
68
code
=
static_cast<
grpc::StatusCode
>
(
from
.code());
69
}
70
*
to
=
grpc::Status
(
code
,
from
.message(),
from
.SerializeAsString());
71
return
grpc::Status::OK
;
72
}
73
74
}
// namespace grpc
75
76
#endif // GRPCPP_SUPPORT_ERROR_DETAILS_H
grpc
Definition:
grpcpp/alarm.h:33
to
size_t to
Definition:
abseil-cpp/absl/container/internal/layout_test.cc:1385
T
#define T(upbtypeconst, upbtype, ctype, default_value)
grpc.StatusCode.FAILED_PRECONDITION
tuple FAILED_PRECONDITION
Definition:
src/python/grpcio/grpc/__init__.py:272
from
size_t from
Definition:
abseil-cpp/absl/container/internal/layout_test.cc:1384
grpc.StatusCode.OK
tuple OK
Definition:
src/python/grpcio/grpc/__init__.py:260
grpc.StatusCode
Definition:
src/python/grpcio/grpc/__init__.py:232
grpc.StatusCode.UNKNOWN
tuple UNKNOWN
Definition:
src/python/grpcio/grpc/__init__.py:262
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::protobuf::util::Status
GRPC_CUSTOM_UTIL_STATUS Status
Definition:
include/grpcpp/impl/codegen/config_protobuf.h:93
grpc.StatusCode.INVALID_ARGUMENT
tuple INVALID_ARGUMENT
Definition:
src/python/grpcio/grpc/__init__.py:263
grpc::Status
Definition:
include/grpcpp/impl/codegen/status.h:35
grpc::SetErrorDetails
grpc::Status SetErrorDetails(const T &from, grpc::Status *to)
Definition:
grpcpp/support/error_details.h:61
grpc::ExtractErrorDetails
grpc::Status ExtractErrorDetails(const grpc::Status &from, T *to)
Definition:
grpcpp/support/error_details.h:38
code
Definition:
bloaty/third_party/zlib/contrib/infback9/inftree9.h:24
status.h
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:19