View on GitHub
jbson
C++11/1y BSON library
error.hpp
1 // Copyright Christian Manning 2013.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 
6 #ifndef JBSON_ERROR_HPP
7 #define JBSON_ERROR_HPP
8 
9 #include <exception>
10 #include <typeindex>
11 
12 #include "./config.hpp"
13 
14 JBSON_PUSH_DISABLE_DOCUMENTATION_WARNING
15 #include <boost/exception/all.hpp>
16 JBSON_CLANG_POP_WARNINGS
17 
18 namespace jbson {
19 
23 struct jbson_error : virtual std::exception, virtual boost::exception {
25  const char* what() const noexcept override { return "jbson_error"; }
26 };
27 
33  const char* what() const noexcept override { return "invalid_element_type"; }
34 };
35 
41  const char* what() const noexcept override { return "incompatible_element_conversion"; }
42 };
43 
49  const char* what() const noexcept override { return "incompatible_type_conversion"; }
50 };
51 
57  const char* what() const noexcept override { return "invalid_element_size"; }
58 };
59 
60 enum class element_type : uint8_t;
61 
62 namespace detail {
63 
64 using expected_type = boost::error_info<struct expected_type_, std::type_index>;
65 using actual_type = boost::error_info<struct actual_type_, std::type_index>;
66 using expected_size = boost::error_info<struct expected_size_, ptrdiff_t>;
67 using actual_size = boost::error_info<struct actual_size_, ptrdiff_t>;
68 using expected_element_type = boost::error_info<struct expected_element_type_, element_type>;
69 using actual_element_type = boost::error_info<struct actual_element_type_, element_type>;
70 
71 } // namespace detail
72 } // namespace jbson
73 
74 #endif // JBSON_ERROR_HPP
element_type
The element_type enum represents a BSON data type.
Definition: element_fwd.hpp:36
const char * what() const noexceptoverride
Returns name of exception.
Definition: error.hpp:57
const char * what() const noexceptoverride
Returns name of exception.
Definition: error.hpp:25
const char * what() const noexceptoverride
Returns name of exception.
Definition: error.hpp:41
Exception thrown when an element has a value not convertible to that requested.
Definition: error.hpp:47
const char * what() const noexceptoverride
Returns name of exception.
Definition: error.hpp:49
const char * what() const noexceptoverride
Returns name of exception.
Definition: error.hpp:33
Exception type. Base class of all exceptions thrown directly by jbson.
Definition: error.hpp:23
Exception thrown when an element's data size differs from that reported.
Definition: error.hpp:55
Exception type thrown when a call to get() has an incorrect type parameter.
Definition: error.hpp:39
Exception type thrown when an element has a type value not represented by element_type.
Definition: error.hpp:31