/src/Fast-DDS/thirdparty/boost/include/boost/interprocess/exceptions.hpp
Line | Count | Source |
1 | | ////////////////////////////////////////////////////////////////////////////// |
2 | | // |
3 | | // (C) Copyright Ion Gaztanaga 2005-2015. Distributed under the Boost |
4 | | // Software License, Version 1.0. (See accompanying file |
5 | | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
6 | | // |
7 | | // See http://www.boost.org/libs/interprocess for documentation. |
8 | | // |
9 | | ////////////////////////////////////////////////////////////////////////////// |
10 | | |
11 | | #ifndef BOOST_INTERPROCESS_EXCEPTIONS_HPP |
12 | | #define BOOST_INTERPROCESS_EXCEPTIONS_HPP |
13 | | |
14 | | #ifndef BOOST_CONFIG_HPP |
15 | | # include <boost/config.hpp> |
16 | | #endif |
17 | | # |
18 | | #if defined(BOOST_HAS_PRAGMA_ONCE) |
19 | | # pragma once |
20 | | #endif |
21 | | |
22 | | #include <boost/interprocess/detail/config_begin.hpp> |
23 | | #include <boost/interprocess/detail/workaround.hpp> |
24 | | #include <boost/interprocess/errors.hpp> |
25 | | #include <stdexcept> |
26 | | |
27 | | //!\file |
28 | | //!Describes exceptions thrown by interprocess classes |
29 | | |
30 | | namespace boost { |
31 | | |
32 | | namespace interprocess { |
33 | | |
34 | | //!This class is the base class of all exceptions |
35 | | //!thrown by boost::interprocess |
36 | | class BOOST_SYMBOL_VISIBLE interprocess_exception : public std::exception |
37 | | { |
38 | | public: |
39 | | interprocess_exception(const char *err) |
40 | 0 | : m_err(other_error) |
41 | 0 | { |
42 | 0 | try { m_str = err; } |
43 | 0 | catch (...) {} |
44 | 0 | } |
45 | | |
46 | | interprocess_exception(const error_info &err_info, const char *str = 0) |
47 | 0 | : m_err(err_info) |
48 | 0 | { |
49 | 0 | try{ |
50 | 0 | if(m_err.get_native_error() != 0){ |
51 | 0 | fill_system_message(m_err.get_native_error(), m_str); |
52 | 0 | } |
53 | 0 | else if(str){ |
54 | 0 | m_str = str; |
55 | 0 | } |
56 | 0 | else{ |
57 | 0 | m_str = "boost::interprocess_exception::library_error"; |
58 | 0 | } |
59 | 0 | } |
60 | 0 | catch(...){} |
61 | 0 | } |
62 | | |
63 | 0 | virtual ~interprocess_exception() BOOST_NOEXCEPT_OR_NOTHROW {} |
64 | | |
65 | | virtual const char * what() const BOOST_NOEXCEPT_OR_NOTHROW |
66 | 0 | { return m_str.c_str(); } |
67 | | |
68 | 0 | native_error_t get_native_error()const { return m_err.get_native_error(); } |
69 | | |
70 | | // Note: a value of other_error implies a library (rather than system) error |
71 | 0 | error_code_t get_error_code() const { return m_err.get_error_code(); } |
72 | | |
73 | | #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) |
74 | | private: |
75 | | error_info m_err; |
76 | | std::string m_str; |
77 | | #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED |
78 | | }; |
79 | | |
80 | | //!This is the exception thrown by shared interprocess_mutex family when a deadlock situation |
81 | | //!is detected or when using a interprocess_condition the interprocess_mutex is not locked |
82 | | class BOOST_SYMBOL_VISIBLE lock_exception : public interprocess_exception |
83 | | { |
84 | | public: |
85 | | lock_exception() |
86 | 0 | : interprocess_exception(lock_error) |
87 | 0 | {} |
88 | | |
89 | | virtual const char* what() const BOOST_NOEXCEPT_OR_NOTHROW |
90 | 0 | { return "boost::interprocess::lock_exception"; } |
91 | | }; |
92 | | |
93 | | |
94 | | //!This exception is thrown when a memory request can't be |
95 | | //!fulfilled. |
96 | | class BOOST_SYMBOL_VISIBLE bad_alloc : public interprocess_exception |
97 | | { |
98 | | public: |
99 | 0 | bad_alloc() : interprocess_exception("::boost::interprocess::bad_alloc"){} |
100 | | virtual const char* what() const BOOST_NOEXCEPT_OR_NOTHROW |
101 | 0 | { return "boost::interprocess::bad_alloc"; } |
102 | | }; |
103 | | |
104 | | } // namespace interprocess { |
105 | | |
106 | | } // namespace boost |
107 | | |
108 | | #include <boost/interprocess/detail/config_end.hpp> |
109 | | |
110 | | #endif // BOOST_INTERPROCESS_EXCEPTIONS_HPP |