MongoDB C++ Driver 4.4.0
Loading...
Searching...
No Matches
exception.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <mongocxx/v1/exception-fwd.hpp> // IWYU pragma: export
18
19//
20
22
25
27
28#include <memory>
29#include <system_error>
30#include <type_traits>
31
32namespace mongocxx {
33namespace v1 {
34
45
50
54inline std::error_condition make_error_condition(source_errc code) {
55 return {static_cast<int>(code), v1::source_error_category()};
56}
57
66
70MONGOCXX_ABI_EXPORT_CDECL(std::error_category const&) type_error_category();
71
75inline std::error_condition make_error_condition(type_errc code) {
76 return {static_cast<int>(code), v1::type_error_category()};
77}
78
79BSONCXX_PRIVATE_WARNINGS_PUSH();
80BSONCXX_PRIVATE_WARNINGS_DISABLE(MSVC(4251));
81BSONCXX_PRIVATE_WARNINGS_DISABLE(MSVC(4275));
82
89class exception : public std::system_error {
90 private:
91 class impl;
92 std::shared_ptr<impl> _impl;
93
94 public:
101
102 class internal;
103
104 private:
105 MONGOCXX_ABI_NO_EXPORT /* explicit(false) */
106 exception(std::error_code ec, char const* message, std::unique_ptr<impl> impl);
107
108 MONGOCXX_ABI_NO_EXPORT /* explicit(false) */
109 exception(std::error_code ec, std::unique_ptr<impl> impl);
110
111 MONGOCXX_ABI_NO_EXPORT virtual void key_function() const;
112};
113
114BSONCXX_PRIVATE_WARNINGS_POP();
115
116} // namespace v1
117} // namespace mongocxx
118
119template <>
120struct std::is_error_condition_enum<mongocxx::v1::source_errc> : true_type {};
121
122template <>
123struct std::is_error_condition_enum<mongocxx::v1::type_errc> : true_type {};
124
126
For internal use only!
A polyfill for std::string_view.
Definition string_view.hpp:412
bool has_error_label(bsoncxx::v1::stdx::string_view label) const
Return true if this exception contains the specified error label.
Provides macros to control the set of symbols exported in the ABI.
#define MONGOCXX_ABI_CDECL
Expands to __cdecl when built with MSVC on Windows.
Definition export.hpp:49
#define MONGOCXX_ABI_NO_EXPORT
Excludes the associated entity from being part of the ABI.
Definition export.hpp:20
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v1 macro guard postlude header.
The mongocxx v1 macro guard prelude header.
Declares mongocxx error-handling utilities.
Declares entities whose ABI stability is guaranteed for documented symbols.
source_errc
Enumeration identifying the source of a mongocxx::v1 error.
Definition exception.hpp:38
@ mongocrypt
From the mongocrypt library.
Definition exception.hpp:42
@ mongoc
From the mongoc library.
Definition exception.hpp:41
@ server
From the MongoDB server.
Definition exception.hpp:43
@ zero
Zero.
Definition exception.hpp:39
std::error_condition make_error_condition(source_errc code)
Support implicit conversion to std::error_condition.
Definition exception.hpp:54
type_errc
Enumeration identifying the type (cause) of a mongocxx::v1 error.
Definition exception.hpp:61
@ runtime_error
An erroneous condition was detected at runtime.
Definition exception.hpp:64
@ invalid_argument
An invalid argument passed to the throwing function.
Definition exception.hpp:63
std::error_category const & type_error_category()
The error category for mongocxx::v1::type_errc.
std::error_category const & source_error_category()
The error category for mongocxx::v1::source_errc.
The top-level namespace within which all mongocxx library entities are declared.
Provides std::string_view-related polyfills for library API usage.