1 //////////////////////////////////////////////////////////////////////////////
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)
7 // See http://www.boost.org/libs/interprocess for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #ifndef BOOST_INTERPROCESS_EXCEPTIONS_HPP
12 #define BOOST_INTERPROCESS_EXCEPTIONS_HPP
14 #ifndef BOOST_CONFIG_HPP
15 # include <boost/config.hpp>
18 #if defined(BOOST_HAS_PRAGMA_ONCE)
22 #include <boost/interprocess/detail/config_begin.hpp>
23 #include <boost/interprocess/detail/workaround.hpp>
24 #include <boost/interprocess/errors.hpp>
28 //!Describes exceptions thrown by interprocess classes
32 namespace interprocess {
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
39 interprocess_exception(const char *err)
46 interprocess_exception(const error_info &err_info, const char *str = 0)
50 if(m_err.get_native_error() != 0){
51 fill_system_message(m_err.get_native_error(), m_str);
57 m_str = "boost::interprocess_exception::library_error";
63 virtual ~interprocess_exception() throw(){}
65 virtual const char * what() const throw()
66 { return m_str.c_str(); }
68 native_error_t get_native_error()const { return m_err.get_native_error(); }
70 // Note: a value of other_error implies a library (rather than system) error
71 error_code_t get_error_code() const { return m_err.get_error_code(); }
73 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
77 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
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
86 : interprocess_exception(lock_error)
89 virtual const char* what() const throw()
90 { return "boost::interprocess::lock_exception"; }
94 //!This exception is thrown when a memory request can't be
96 class BOOST_SYMBOL_VISIBLE bad_alloc : public interprocess_exception
99 bad_alloc() : interprocess_exception("::boost::interprocess::bad_alloc"){}
100 virtual const char* what() const throw()
101 { return "boost::interprocess::bad_alloc"; }
104 } // namespace interprocess {
108 #include <boost/interprocess/detail/config_end.hpp>
110 #endif // BOOST_INTERPROCESS_EXCEPTIONS_HPP