userver
C++ Async Framework
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
};
57
58
TransactionException(
Type
type, std::string_view what);
59
60
Type
GetType()
const
noexcept
{
return
type_; }
61
62
private
:
63
Type
type_;
64
};
65
66
/// Network (connectivity) error
67
class
NetworkException
:
public
MongoException
{
68
public
:
69
using
MongoException
::MongoException;
70
};
71
72
/// No server available to satisfy request constraints
73
class
ClusterUnavailableException
:
public
MongoException
{
74
public
:
75
using
MongoException
::MongoException;
76
};
77
78
/// Incompatible server version
79
class
IncompatibleServerException
:
public
MongoException
{
80
public
:
81
using
MongoException
::MongoException;
82
};
83
84
/// Authentication error
85
class
AuthenticationException
:
public
MongoException
{
86
public
:
87
using
MongoException
::MongoException;
88
};
89
90
/// Generic query error
91
class
QueryException
:
public
MongoException
{
92
public
:
93
using
MongoException
::MongoException;
94
};
95
96
/// Query argument validation error
97
class
InvalidQueryArgumentException
:
public
QueryException
{
98
public
:
99
using
QueryException
::QueryException;
100
};
101
102
/// Server-side error
103
class
ServerException
:
public
QueryException
{
104
public
:
105
explicit
ServerException(
int
code)
106
: code_(code)
107
{}
108
109
int
Code()
const
{
return
code_; }
110
111
private
:
112
int
code_;
113
};
114
115
/// Write concern error
116
class
WriteConcernException
:
public
ServerException
{
117
public
:
118
using
ServerException
::ServerException;
119
};
120
121
/// Duplicate key error
122
class
DuplicateKeyException
:
public
ServerException
{
123
public
:
124
using
ServerException
::ServerException;
125
};
126
127
}
// namespace storages::mongo
128
129
USERVER_NAMESPACE_END
userver
storages
mongo
exception.hpp
Generated on Tue Jan 27 2026 16:48:32 for userver by
Doxygen
1.13.2