Loading...
Searching...
No Matches
exception.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <mongocxx/v1/exception-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/detail/prelude.hpp>
#include <bsoncxx/v1/detail/macros.hpp>
#include <bsoncxx/v1/stdx/string_view.hpp>
#include <mongocxx/v1/config/export.hpp>
#include <memory>
#include <system_error>
#include <type_traits>
namespace mongocxx {
namespace v1 {
enum class source_errc {
zero,
mongocxx,
mongoc,
mongocrypt,
server,
};
MONGOCXX_ABI_EXPORT_CDECL(std::error_category const&) source_error_category();
inline std::error_condition make_error_condition(source_errc code) {
return {static_cast<int>(code), v1::source_error_category()};
}
enum class type_errc {
zero,
invalid_argument,
runtime_error,
};
MONGOCXX_ABI_EXPORT_CDECL(std::error_category const&) type_error_category();
inline std::error_condition make_error_condition(type_errc code) {
return {static_cast<int>(code), v1::type_error_category()};
}
BSONCXX_PRIVATE_WARNINGS_PUSH();
BSONCXX_PRIVATE_WARNINGS_DISABLE(MSVC(4251));
BSONCXX_PRIVATE_WARNINGS_DISABLE(MSVC(4275));
class exception : public std::system_error {
private:
class impl;
std::shared_ptr<impl> _impl;
public:
bool MONGOCXX_ABI_CDECL has_error_label(bsoncxx::v1::stdx::string_view label) const;
class internal;
private:
MONGOCXX_ABI_NO_EXPORT /* explicit(false) */
exception(std::error_code ec, char const* message, std::unique_ptr<impl> impl);
MONGOCXX_ABI_NO_EXPORT /* explicit(false) */
exception(std::error_code ec, std::unique_ptr<impl> impl);
MONGOCXX_ABI_NO_EXPORT virtual void key_function() const;
};
BSONCXX_PRIVATE_WARNINGS_POP();
} // namespace v1
} // namespace mongocxx
template <>
struct std::is_error_condition_enum<mongocxx::v1::source_errc> : true_type {};
template <>
struct std::is_error_condition_enum<mongocxx::v1::type_errc> : true_type {};
#include <mongocxx/v1/detail/postlude.hpp>
macros.hpp
For internal use only!
bsoncxx::v1::stdx::string_view
A polyfill for std::string_view.
Definition string_view.hpp:412
mongocxx::v1::exception::has_error_label
bool has_error_label(bsoncxx::v1::stdx::string_view label) const
Return true if this exception contains the specified error label.
export.hpp
Provides macros to control the set of symbols exported in the ABI.
MONGOCXX_ABI_CDECL
#define MONGOCXX_ABI_CDECL
Expands to __cdecl when built with MSVC on Windows.
Definition export.hpp:49
MONGOCXX_ABI_NO_EXPORT
#define MONGOCXX_ABI_NO_EXPORT
Excludes the associated entity from being part of the ABI.
Definition export.hpp:20
MONGOCXX_ABI_EXPORT_CDECL
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
postlude.hpp
The mongocxx v1 macro guard postlude header.
prelude.hpp
The mongocxx v1 macro guard prelude header.
exception-fwd.hpp
Declares mongocxx error-handling utilities.
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx::v1::source_errc
source_errc
Enumeration identifying the source of a mongocxx::v1 error.
Definition exception.hpp:38
mongocxx::v1::source_errc::mongocrypt
@ mongocrypt
From the mongocrypt library.
Definition exception.hpp:42
mongocxx::v1::source_errc::mongoc
@ mongoc
From the mongoc library.
Definition exception.hpp:41
mongocxx::v1::source_errc::server
@ server
From the MongoDB server.
Definition exception.hpp:43
mongocxx::v1::source_errc::zero
@ zero
Zero.
Definition exception.hpp:39
mongocxx::v1::make_error_condition
std::error_condition make_error_condition(source_errc code)
Support implicit conversion to std::error_condition.
Definition exception.hpp:54
mongocxx::v1::type_errc
type_errc
Enumeration identifying the type (cause) of a mongocxx::v1 error.
Definition exception.hpp:61
mongocxx::v1::type_errc::runtime_error
@ runtime_error
An erroneous condition was detected at runtime.
Definition exception.hpp:64
mongocxx::v1::type_errc::invalid_argument
@ invalid_argument
An invalid argument passed to the throwing function.
Definition exception.hpp:63
mongocxx::v1::type_error_category
std::error_category const & type_error_category()
The error category for mongocxx::v1::type_errc.
mongocxx::v1::source_error_category
std::error_category const & source_error_category()
The error category for mongocxx::v1::source_errc.
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
string_view.hpp
Provides std::string_view-related polyfills for library API usage.