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