userver: userver/storages/mongo/exception.hpp Source File
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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
14 public:
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
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
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
52 public:
53 using MongoException::MongoException;
54};
55
56/// No server available to satisfy request constraints
58 public:
59 using MongoException::MongoException;
60};
61
62/// Incompatible server version
64 public:
65 using MongoException::MongoException;
66};
67
68/// Authentication error
70 public:
71 using MongoException::MongoException;
72};
73
74/// Generic query error
76 public:
77 using MongoException::MongoException;
78};
79
80/// Query argument validation error
82 public:
83 using QueryException::QueryException;
84};
85
86/// Server-side error
88 public:
89 explicit ServerException(int code) : code_(code) {}
90
91 int Code() const { return code_; }
92
93 private:
94 int code_;
95};
96
97/// Write concern error
99 public:
100 using ServerException::ServerException;
101};
102
103/// Duplicate key error
105 public:
106 using ServerException::ServerException;
107};
108
109} // namespace storages::mongo
110
111USERVER_NAMESPACE_END