userver
C++ Async Framework
Loading...
Searching...
No Matches
mongo_error.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/mongo/mongo_error.hpp
4
/// @brief @copybrief storages::mongo::MongoError
5
6
#
include
<
string
>
7
8
#
include
<
bson
/
bson
.
h
>
9
10
USERVER_NAMESPACE_BEGIN
11
12
namespace
storages::mongo {
13
14
/// @brief MongoDB driver error (wrapper around bson_error_t)
15
class
MongoError
{
16
public
:
17
/// Error kinds
18
enum
class
Kind
{
19
kNoError
,
///< Error was not reported correctly
20
kNetwork
,
///< @copybrief NetworkException
21
kClusterUnavailable
,
///< @copybrief ClusterUnavailableException
22
kIncompatibleServer
,
///< @copybrief IncompatibleServerException
23
kAuthentication
,
///< @copybrief AuthenticationException
24
kQuery
,
///< @copybrief QueryException
25
kInvalidQueryArgument
,
///< @copybrief InvalidQueryArgumentException
26
kServer
,
///< @copybrief ServerException
27
kWriteConcern
,
///< @copybrief WriteConcernException
28
kDuplicateKey
,
///< @copybrief DuplicateKeyException
29
kOther
///< Unclassified error
30
};
31
32
/// @cond
33
/// Creates a not-an-error
34
MongoError();
35
/// @endcond
36
37
/// Checks whether an error is set up
38
explicit
operator
bool
()
const
;
39
40
/// Checks whether this is a server error
41
bool
IsServerError
()
const
;
42
Kind
GetKind()
const
;
43
44
uint32_t Code()
const
;
45
const
char
* Message()
const
;
46
47
/// @cond
48
/// Error domain, for internal use
49
uint32_t Domain()
const
;
50
51
/// Returns native type, internal use only
52
bson_error_t* GetNative();
53
/// @endcond
54
55
/// Unconditionally throws specialized MongoException
56
[[
noreturn
]]
void
Throw
(std::string prefix)
const
;
57
58
private
:
59
bson_error_t value_;
60
};
61
62
}
// namespace storages::mongo
63
64
USERVER_NAMESPACE_END
userver
storages
mongo
mongo_error.hpp
Generated on Thu May 21 2026 16:21:14 for userver by
Doxygen
1.13.2