userver
C++ Async Framework
Loading...
Searching...
No Matches
error.hpp
1
#
pragma
once
2
3
#
include
<
exception
>
4
#
include
<
string
>
5
#
include
<
string_view
>
6
#
include
<
system_error
>
7
8
#
include
<
userver
/
clients
/
http
/
error_kind
.
hpp
>
9
#
include
<
userver
/
clients
/
http
/
local_stats
.
hpp
>
10
11
USERVER_NAMESPACE_BEGIN
12
13
namespace
clients::http {
14
15
/// Exception with string
16
class
BaseException
:
public
std::exception {
17
public
:
18
BaseException(std::string message,
const
LocalStats& stats,
ErrorKind
error_kind)
19
: message_(std::move(message)),
20
stats_(stats),
21
error_kind_(error_kind)
22
{}
23
~BaseException()
override
=
default
;
24
25
const
char
* what()
const
noexcept
override
{
return
message_.c_str(); }
26
27
ErrorKind
GetErrorKind()
const
{
return
error_kind_; }
28
29
const
LocalStats& GetStats()
const
{
return
stats_; }
30
31
private
:
32
std::string message_;
33
LocalStats stats_;
34
ErrorKind
error_kind_;
35
};
36
37
/// Exception with string and error_code
38
class
BaseCodeException
:
public
BaseException
{
39
public
:
40
BaseCodeException(std::error_code ec, std::string_view message, std::string_view url,
const
LocalStats& stats);
41
~BaseCodeException()
override
=
default
;
42
43
const
std::error_code& error_code()
const
noexcept
{
return
ec_; }
44
45
private
:
46
std::error_code ec_;
47
};
48
49
class
TimeoutException
:
public
BaseException
{
50
public
:
51
TimeoutException(std::string_view message,
const
LocalStats& stats);
52
~TimeoutException()
override
=
default
;
53
};
54
55
class
CancelException
:
public
BaseException
{
56
public
:
57
using
BaseException
::BaseException;
58
~CancelException()
override
=
default
;
59
};
60
61
class
SSLException
:
public
BaseCodeException
{
62
public
:
63
using
BaseCodeException
::BaseCodeException;
64
~SSLException()
override
=
default
;
65
};
66
67
class
TechnicalError
:
public
BaseCodeException
{
68
public
:
69
using
BaseCodeException
::BaseCodeException;
70
~TechnicalError()
override
=
default
;
71
};
72
73
class
BadArgumentException
:
public
BaseCodeException
{
74
public
:
75
using
BaseCodeException
::BaseCodeException;
76
~BadArgumentException()
override
=
default
;
77
};
78
79
class
TooManyRedirectsException
:
public
BaseCodeException
{
80
public
:
81
using
BaseCodeException
::BaseCodeException;
82
~TooManyRedirectsException()
override
=
default
;
83
};
84
85
class
NetworkProblemException
:
public
BaseCodeException
{
86
public
:
87
using
BaseCodeException
::BaseCodeException;
88
~NetworkProblemException()
override
=
default
;
89
};
90
91
class
DNSProblemException
:
public
BaseCodeException
{
92
public
:
93
using
BaseCodeException
::BaseCodeException;
94
~DNSProblemException()
override
=
default
;
95
};
96
97
class
AuthFailedException
:
public
BaseCodeException
{
98
public
:
99
using
BaseCodeException
::BaseCodeException;
100
~AuthFailedException()
override
=
default
;
101
};
102
103
/// Base class for HttpClientException and HttpServerException
104
class
HttpException
:
public
BaseException
{
105
public
:
106
HttpException(
int
code,
const
LocalStats& stats, std::string_view message,
ErrorKind
error_kind);
107
~HttpException()
override
=
default
;
108
109
int
code()
const
{
return
code_; }
110
111
private
:
112
int
code_;
113
};
114
115
class
HttpClientException
:
public
HttpException
{
116
public
:
117
HttpClientException(
int
code,
const
LocalStats& stats);
118
HttpClientException(
int
code,
const
LocalStats& stats, std::string_view message);
119
~HttpClientException()
override
=
default
;
120
};
121
122
class
HttpServerException
:
public
HttpException
{
123
public
:
124
HttpServerException(
int
code,
const
LocalStats& stats);
125
HttpServerException(
int
code,
const
LocalStats& stats, std::string_view message);
126
~HttpServerException()
override
=
default
;
127
};
128
129
/// map error_code to exceptions
130
std::exception_ptr
PrepareException
(std::error_code ec, std::string_view url,
const
LocalStats& stats);
131
132
}
// namespace clients::http
133
134
USERVER_NAMESPACE_END
userver
clients
http
error.hpp
Generated on Fri Dec 5 2025 12:18:19 for userver by
Doxygen
1.13.2