MongoDB C++ Driver 4.2.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 <bsoncxx/v1/exception-fwd.hpp> // IWYU pragma: export
18
19//
20
22
25
26#include <system_error>
27#include <type_traits>
28
29namespace bsoncxx {
30namespace v1 {
31
42
48BSONCXX_ABI_EXPORT_CDECL(std::error_category const&) source_error_category();
49
55inline std::error_condition make_error_condition(source_errc code) {
56 return {static_cast<int>(code), v1::source_error_category()};
57}
58
69
75BSONCXX_ABI_EXPORT_CDECL(std::error_category const&) type_error_category();
76
82inline std::error_condition make_error_condition(type_errc code) {
83 return {static_cast<int>(code), v1::type_error_category()};
84}
85
86BSONCXX_PRIVATE_WARNINGS_PUSH();
87BSONCXX_PRIVATE_WARNINGS_DISABLE(MSVC(4251));
88BSONCXX_PRIVATE_WARNINGS_DISABLE(MSVC(4275));
89
98class exception : public std::system_error {
99 public:
100 using std::system_error::system_error;
101
102 private:
103 BSONCXX_ABI_NO_EXPORT virtual void key_function() const;
104};
105
106BSONCXX_PRIVATE_WARNINGS_POP();
107
108} // namespace v1
109} // namespace bsoncxx
110
111template <>
112struct std::is_error_condition_enum<bsoncxx::v1::source_errc> : true_type {};
113
114template <>
115struct std::is_error_condition_enum<bsoncxx::v1::type_errc> : true_type {};
116
118
Provides macros to control the set of symbols exported in the ABI.
#define BSONCXX_ABI_NO_EXPORT
Excludes the associated entity from being part of the ABI.
Definition export.hpp:20
#define BSONCXX_ABI_EXPORT_CDECL(...)
Equivalent to BSONCXX_ABI_EXPORT with BSONCXX_ABI_CDECL.
Definition export.hpp:52
For internal use only!
The bsoncxx v1 macro guard postlude header.
The bsoncxx v1 macro guard prelude header.
Declares bsoncxx error-handling utilities.
Base class for all exceptions thrown by bsoncxx::v1.
Definition exception.hpp:98
Declares entities whose ABI stability is guaranteed for documented symbols.
std::error_category const & type_error_category()
The error category for bsoncxx::v1::type_errc.
std::error_condition make_error_condition(source_errc code)
Support implicit conversion to std::error_condition.
Definition exception.hpp:55
source_errc
Enumeration identifying the source of a bsoncxx::v1 error.
Definition exception.hpp:37
@ bson
From the bson library.
Definition exception.hpp:40
@ zero
Zero.
Definition exception.hpp:38
type_errc
Enumeration identifying the type (cause) of a bsoncxx::v1 error.
Definition exception.hpp:64
@ runtime_error
An erroneous condition was detected at runtime.
Definition exception.hpp:67
@ invalid_argument
An invalid argument passed to the throwing function.
Definition exception.hpp:66
std::error_category const & source_error_category()
The error category for bsoncxx::v1::source_errc.
The top-level namespace within which all bsoncxx library entities are declared.