userver: userver/storages/mongo/exception.hpp Source File
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
8USERVER_NAMESPACE_BEGIN
9
10namespace storages::mongo {
11
12/// Generic mongo-related exception
13class MongoException : public utils::TracefulException {
14public:
15 MongoException();
16
17 explicit MongoException(std::string_view what);
18};
19
20/// Config validation error
22 using MongoException::MongoException;
23};
24
25/// The current task has been cancelled, e.g. by deadline propagation
27public:
28 struct ByDeadlinePropagation final {};
29
30 using MongoException::MongoException;
31
32 explicit CancelledException(ByDeadlinePropagation);
33
34 bool IsByDeadlinePropagation() const;
35
36private:
37 bool by_deadline_propagation_{false};
38};
39
40/// Nonexistent pool requested from the set
42 using MongoException::MongoException;
43};
44
45/// Pool refused to satisfy connection request due to high load
47 using MongoException::MongoException;
48};
49
50/// Network (connectivity) error
52public:
53 using MongoException::MongoException;
54};
55
56/// No server available to satisfy request constraints
58public:
59 using MongoException::MongoException;
60};
61
62/// Incompatible server version
64public:
65 using MongoException::MongoException;
66};
67
68/// Authentication error
70public:
71 using MongoException::MongoException;
72};
73
74/// Generic query error
76public:
77 using MongoException::MongoException;
78};
79
80/// Query argument validation error
82public:
83 using QueryException::QueryException;
84};
85
86/// Server-side error
88public:
89 explicit ServerException(int code)
90 : code_(code)
91 {}
92
93 int Code() const { return code_; }
94
95private:
96 int code_;
97};
98
99/// Write concern error
101public:
102 using ServerException::ServerException;
103};
104
105/// Duplicate key error
107public:
108 using ServerException::ServerException;
109};
110
111} // namespace storages::mongo
112
113USERVER_NAMESPACE_END