1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2005-2008. 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 #if (defined _MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/interprocess/detail/config_begin.hpp>
19 #include <boost/interprocess/detail/workaround.hpp>
20 #include <boost/interprocess/errors.hpp>
25 //!Describes exceptions thrown by interprocess classes
29 namespace interprocess
{
31 //!This class is the base class of all exceptions
32 //!thrown by boost::interprocess
33 class interprocess_exception
: public std::exception
36 interprocess_exception(error_code_t ec
= other_error
)
39 try { m_str
= "boost::interprocess_exception::library_error"; }
43 interprocess_exception(native_error_t sys_err_code
)
46 try { fill_system_message(m_err
.get_native_error(), m_str
); }
50 interprocess_exception(const error_info
&err_info
)
54 if(m_err
.get_native_error() != 0){
55 fill_system_message(m_err
.get_native_error(), m_str
);
58 m_str = "boost::interprocess_exception::library_error";
64 virtual ~interprocess_exception() throw(){}
66 virtual const char * what() const throw()
67 { return m_str
.c_str(); }
69 native_error_t
get_native_error()const { return m_err
.get_native_error(); }
71 // Note: a value of other_error implies a library (rather than system) error
72 error_code_t
get_error_code() const { return m_err
.get_error_code(); }
81 //!This is the exception thrown by shared interprocess_mutex family when a deadlock situation
82 //!is detected or when using a interprocess_condition the interprocess_mutex is not locked
83 class lock_exception
: public interprocess_exception
87 : interprocess_exception(lock_error
)
90 virtual const char* what() const throw()
91 { return "boost::interprocess::lock_exception"; }
94 //!This is the exception thrown by named interprocess_semaphore when a deadlock situation
95 //!is detected or when an error is detected in the post/wait operation
97 class sem_exception : public interprocess_exception
101 : interprocess_exception(lock_error)
104 virtual const char* what() const throw()
105 { return "boost::interprocess::sem_exception"; }
108 //!This is the exception thrown by synchronization objects when there is
109 //!an error in a wait() function
111 class wait_exception : public interprocess_exception
114 virtual const char* what() const throw()
115 { return "boost::interprocess::wait_exception"; }
119 //!This exception is thrown when a named object is created
120 //!in "open_only" mode and the resource was not already created
122 class not_previously_created : public interprocess_exception
125 virtual const char* what() const throw()
126 { return "boost::interprocess::not_previously_created"; }
130 //!This exception is thrown when a memory request can't be
132 class bad_alloc
: public interprocess_exception
135 virtual const char* what() const throw()
136 { return "boost::interprocess::bad_alloc"; }
139 } // namespace interprocess {
143 #include <boost/interprocess/detail/config_end.hpp>
145 #endif // BOOST_INTERPROCESS_EXCEPTIONS_HPP