userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
exception.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/mongo/exception.hpp
4
/// @brief MongoDB-specific exceptions
5
6
#
include
<
userver
/
utils
/
traceful_exception
.
hpp
>
7
8
USERVER_NAMESPACE_BEGIN
9
10
namespace
storages::mongo {
11
12
/// Generic mongo-related exception
13
class
MongoException
:
public
utils
::TracefulException {
14
public
:
15
MongoException();
16
17
explicit
MongoException(std::string_view what);
18
};
19
20
/// Config validation error
21
class
InvalidConfigException
:
public
MongoException
{
22
using
MongoException
::MongoException;
23
};
24
25
/// The current task has been cancelled, e.g. by deadline propagation
26
class
CancelledException
:
public
MongoException
{
27
public
:
28
struct
ByDeadlinePropagation
final
{};
29
30
using
MongoException
::MongoException;
31
32
explicit
CancelledException(ByDeadlinePropagation);
33
34
bool
IsByDeadlinePropagation()
const
;
35
36
private
:
37
bool
by_deadline_propagation_{
false
};
38
};
39
40
/// Nonexistent pool requested from the set
41
class
PoolNotFoundException
:
public
MongoException
{
42
using
MongoException
::MongoException;
43
};
44
45
/// Pool refused to satisfy connection request due to high load
46
class
PoolOverloadException
:
public
MongoException
{
47
using
MongoException
::MongoException;
48
};
49
50
/// Transaction-related exception
51
class
TransactionException
:
public
MongoException
{
52
public
:
53
enum
class
Type
{
54
kTransientError
,
///< Transient error that may be retried
55
kPermanentError
,
///< Permanent error, cannot retry
56
kUnknownCommitResult
,
///< Retry commit on the same transaction; do not repeat its operations
57
};
58
59
TransactionException(
Type
type, std::string_view what);
60
61
Type
GetType()
const
noexcept
{
return
type_; }
62
63
private
:
64
Type
type_;
65
};
66
67
/// Network (connectivity) error
68
class
NetworkException
:
public
MongoException
{
69
public
:
70
using
MongoException
::MongoException;
71
};
72
73
/// No server available to satisfy request constraints
74
class
ClusterUnavailableException
:
public
MongoException
{
75
public
:
76
using
MongoException
::MongoException;
77
};
78
79
/// Incompatible server version
80
class
IncompatibleServerException
:
public
MongoException
{
81
public
:
82
using
MongoException
::MongoException;
83
};
84
85
/// Authentication error
86
class
AuthenticationException
:
public
MongoException
{
87
public
:
88
using
MongoException
::MongoException;
89
};
90
91
/// Generic query error
92
class
QueryException
:
public
MongoException
{
93
public
:
94
using
MongoException
::MongoException;
95
};
96
97
/// Query argument validation error
98
class
InvalidQueryArgumentException
:
public
QueryException
{
99
public
:
100
using
QueryException
::QueryException;
101
};
102
103
/// Server-side error
104
class
ServerException
:
public
QueryException
{
105
public
:
106
explicit
ServerException(
int
code)
107
: code_(code)
108
{}
109
110
int
Code()
const
{
return
code_; }
111
112
private
:
113
int
code_;
114
};
115
116
/// Write concern error
117
class
WriteConcernException
:
public
ServerException
{
118
public
:
119
using
ServerException
::ServerException;
120
};
121
122
/// Duplicate key error
123
class
DuplicateKeyException
:
public
ServerException
{
124
public
:
125
using
ServerException
::ServerException;
126
};
127
128
}
// namespace storages::mongo
129
130
USERVER_NAMESPACE_END
userver
storages
mongo
exception.hpp
Generated on
for userver by
Doxygen
1.17.0