userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
exceptions.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/ugrpc/client/exceptions.hpp
4
/// @brief Exceptions thrown by gRPC client streams
5
6
#
include
<
exception
>
7
#
include
<
string
>
8
#
include
<
string_view
>
9
10
#
include
<
grpcpp
/
support
/
status
.
h
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
/// Asynchronous gRPC driver
15
namespace
ugrpc {}
16
17
/// Client-side utilities
18
namespace
ugrpc::client {
19
20
/// @brief Base exception for all the client errors
21
class
BaseError
:
public
std
::
exception
{
22
public
:
23
explicit
BaseError(std::string message);
24
25
const
char
* what()
const
noexcept
override;
26
27
private
:
28
std::string message_;
29
};
30
31
/// @brief Error during an RPC
32
class
RpcError
:
public
BaseError
{
33
public
:
34
RpcError(std::string_view call_name, std::string_view additional_info);
35
};
36
37
/// @brief RPC failed without a gRPC status because it was interrupted at the transport level
38
/// (cancelled via `TryCancel`, or the connection was lost/reset). For a unary call it is thrown
39
/// only when no concrete gRPC status is available; when a status is available it is instead
40
/// surfaced as the corresponding @ref ugrpc::client::ErrorWithStatus. Retryable.
41
/// Note: Deadline expiration throws @ref ugrpc::client::DeadlineExceededError
42
class
RpcInterruptedError
final
:
public
RpcError
{
43
public
:
44
RpcInterruptedError(std::string_view call_name, std::string_view stage);
45
};
46
47
/// @brief RPC failed due to task cancellation
48
class
RpcCancelledError
final
:
public
RpcError
{
49
public
:
50
RpcCancelledError(std::string_view call_name, std::string_view stage);
51
};
52
53
/// @brief Error with grpc::Status details
54
/// @see <grpcpp/impl/codegen/status_code_enum.h> for error code details
55
class
ErrorWithStatus
:
public
RpcError
{
56
public
:
57
ErrorWithStatus(std::string_view call_name, grpc::Status&& status);
58
59
const
grpc::Status& GetStatus()
const
noexcept
;
60
61
private
:
62
grpc::Status status_;
63
};
64
65
/// @brief Concrete errors for all the error codes
66
/// @see <grpcpp/impl/codegen/status_code_enum.h> for error code details
67
/// @{
68
class
CancelledError
final
:
public
ErrorWithStatus
{
69
public
:
70
using
ErrorWithStatus
::ErrorWithStatus;
71
};
72
73
class
UnknownError
final
:
public
ErrorWithStatus
{
74
public
:
75
using
ErrorWithStatus
::ErrorWithStatus;
76
};
77
78
class
InvalidArgumentError
final
:
public
ErrorWithStatus
{
79
public
:
80
using
ErrorWithStatus
::ErrorWithStatus;
81
};
82
83
class
DeadlineExceededError
final
:
public
ErrorWithStatus
{
84
public
:
85
using
ErrorWithStatus
::ErrorWithStatus;
86
};
87
88
class
NotFoundError
final
:
public
ErrorWithStatus
{
89
public
:
90
using
ErrorWithStatus
::ErrorWithStatus;
91
};
92
93
class
AlreadyExistsError
final
:
public
ErrorWithStatus
{
94
public
:
95
using
ErrorWithStatus
::ErrorWithStatus;
96
};
97
98
class
PermissionDeniedError
final
:
public
ErrorWithStatus
{
99
public
:
100
using
ErrorWithStatus
::ErrorWithStatus;
101
};
102
103
class
ResourceExhaustedError
final
:
public
ErrorWithStatus
{
104
public
:
105
using
ErrorWithStatus
::ErrorWithStatus;
106
};
107
108
class
FailedPreconditionError
final
:
public
ErrorWithStatus
{
109
public
:
110
using
ErrorWithStatus
::ErrorWithStatus;
111
};
112
113
class
AbortedError
final
:
public
ErrorWithStatus
{
114
public
:
115
using
ErrorWithStatus
::ErrorWithStatus;
116
};
117
118
class
OutOfRangeError
final
:
public
ErrorWithStatus
{
119
public
:
120
using
ErrorWithStatus
::ErrorWithStatus;
121
};
122
123
class
UnimplementedError
final
:
public
ErrorWithStatus
{
124
public
:
125
using
ErrorWithStatus
::ErrorWithStatus;
126
};
127
128
class
InternalError
final
:
public
ErrorWithStatus
{
129
public
:
130
using
ErrorWithStatus
::ErrorWithStatus;
131
};
132
133
class
UnavailableError
final
:
public
ErrorWithStatus
{
134
public
:
135
using
ErrorWithStatus
::ErrorWithStatus;
136
};
137
138
class
DataLossError
final
:
public
ErrorWithStatus
{
139
public
:
140
using
ErrorWithStatus
::ErrorWithStatus;
141
};
142
143
class
UnauthenticatedError
final
:
public
ErrorWithStatus
{
144
public
:
145
using
ErrorWithStatus
::ErrorWithStatus;
146
};
147
/// @}
148
149
[[noreturn]]
void
ThrowErrorWithStatus(std::string_view call_name, grpc::Status&& status);
150
151
}
// namespace ugrpc::client
152
153
USERVER_NAMESPACE_END
userver
ugrpc
client
exceptions.hpp
Generated on
for userver by
Doxygen
1.17.0