Chris@16
|
1 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 //
|
Chris@16
|
3 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
|
Chris@16
|
4 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 //
|
Chris@16
|
7 // See http://www.boost.org/libs/interprocess for documentation.
|
Chris@16
|
8 //
|
Chris@16
|
9 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_INTERPROCESS_EXCEPTIONS_HPP
|
Chris@16
|
12 #define BOOST_INTERPROCESS_EXCEPTIONS_HPP
|
Chris@16
|
13
|
Chris@101
|
14 #ifndef BOOST_CONFIG_HPP
|
Chris@101
|
15 # include <boost/config.hpp>
|
Chris@101
|
16 #endif
|
Chris@101
|
17 #
|
Chris@101
|
18 #if defined(BOOST_HAS_PRAGMA_ONCE)
|
Chris@16
|
19 # pragma once
|
Chris@16
|
20 #endif
|
Chris@16
|
21
|
Chris@16
|
22 #include <boost/interprocess/detail/config_begin.hpp>
|
Chris@16
|
23 #include <boost/interprocess/detail/workaround.hpp>
|
Chris@16
|
24 #include <boost/interprocess/errors.hpp>
|
Chris@16
|
25 #include <stdexcept>
|
Chris@16
|
26
|
Chris@16
|
27 //!\file
|
Chris@16
|
28 //!Describes exceptions thrown by interprocess classes
|
Chris@16
|
29
|
Chris@16
|
30 namespace boost {
|
Chris@16
|
31
|
Chris@16
|
32 namespace interprocess {
|
Chris@16
|
33
|
Chris@16
|
34 //!This class is the base class of all exceptions
|
Chris@16
|
35 //!thrown by boost::interprocess
|
Chris@16
|
36 class interprocess_exception : public std::exception
|
Chris@16
|
37 {
|
Chris@16
|
38 public:
|
Chris@16
|
39 interprocess_exception(const char *err/*error_code_t ec = other_error*/)
|
Chris@16
|
40 : m_err(other_error)
|
Chris@16
|
41 {
|
Chris@16
|
42 // try { m_str = "boost::interprocess_exception::library_error"; }
|
Chris@16
|
43 try { m_str = err; }
|
Chris@16
|
44 catch (...) {}
|
Chris@16
|
45 }
|
Chris@16
|
46 /*
|
Chris@16
|
47 interprocess_exception(native_error_t sys_err_code)
|
Chris@16
|
48 : m_err(sys_err_code)
|
Chris@16
|
49 {
|
Chris@16
|
50 try { fill_system_message(m_err.get_native_error(), m_str); }
|
Chris@16
|
51 catch (...) {}
|
Chris@16
|
52 }*/
|
Chris@16
|
53
|
Chris@16
|
54 interprocess_exception(const error_info &err_info, const char *str = 0)
|
Chris@16
|
55 : m_err(err_info)
|
Chris@16
|
56 {
|
Chris@16
|
57 try{
|
Chris@16
|
58 if(m_err.get_native_error() != 0){
|
Chris@16
|
59 fill_system_message(m_err.get_native_error(), m_str);
|
Chris@16
|
60 }
|
Chris@16
|
61 else if(str){
|
Chris@16
|
62 m_str = str;
|
Chris@16
|
63 }
|
Chris@16
|
64 else{
|
Chris@16
|
65 m_str = "boost::interprocess_exception::library_error";
|
Chris@16
|
66 }
|
Chris@16
|
67 }
|
Chris@16
|
68 catch(...){}
|
Chris@16
|
69 }
|
Chris@16
|
70
|
Chris@16
|
71 virtual ~interprocess_exception() throw(){}
|
Chris@16
|
72
|
Chris@16
|
73 virtual const char * what() const throw()
|
Chris@16
|
74 { return m_str.c_str(); }
|
Chris@16
|
75
|
Chris@16
|
76 native_error_t get_native_error()const { return m_err.get_native_error(); }
|
Chris@16
|
77
|
Chris@16
|
78 // Note: a value of other_error implies a library (rather than system) error
|
Chris@16
|
79 error_code_t get_error_code() const { return m_err.get_error_code(); }
|
Chris@16
|
80
|
Chris@101
|
81 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
|
Chris@16
|
82 private:
|
Chris@16
|
83 error_info m_err;
|
Chris@16
|
84 std::string m_str;
|
Chris@101
|
85 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
|
Chris@16
|
86 };
|
Chris@16
|
87
|
Chris@16
|
88 //!This is the exception thrown by shared interprocess_mutex family when a deadlock situation
|
Chris@16
|
89 //!is detected or when using a interprocess_condition the interprocess_mutex is not locked
|
Chris@16
|
90 class lock_exception : public interprocess_exception
|
Chris@16
|
91 {
|
Chris@16
|
92 public:
|
Chris@16
|
93 lock_exception()
|
Chris@16
|
94 : interprocess_exception(lock_error)
|
Chris@16
|
95 {}
|
Chris@16
|
96
|
Chris@16
|
97 virtual const char* what() const throw()
|
Chris@16
|
98 { return "boost::interprocess::lock_exception"; }
|
Chris@16
|
99 };
|
Chris@16
|
100
|
Chris@16
|
101 //!This is the exception thrown by named interprocess_semaphore when a deadlock situation
|
Chris@16
|
102 //!is detected or when an error is detected in the post/wait operation
|
Chris@16
|
103 /*
|
Chris@16
|
104 class sem_exception : public interprocess_exception
|
Chris@16
|
105 {
|
Chris@16
|
106 public:
|
Chris@16
|
107 sem_exception()
|
Chris@16
|
108 : interprocess_exception(lock_error)
|
Chris@16
|
109 {}
|
Chris@16
|
110
|
Chris@16
|
111 virtual const char* what() const throw()
|
Chris@16
|
112 { return "boost::interprocess::sem_exception"; }
|
Chris@16
|
113 };
|
Chris@16
|
114 */
|
Chris@16
|
115 //!This is the exception thrown by synchronization objects when there is
|
Chris@16
|
116 //!an error in a wait() function
|
Chris@16
|
117 /*
|
Chris@16
|
118 class wait_exception : public interprocess_exception
|
Chris@16
|
119 {
|
Chris@16
|
120 public:
|
Chris@16
|
121 virtual const char* what() const throw()
|
Chris@16
|
122 { return "boost::interprocess::wait_exception"; }
|
Chris@16
|
123 };
|
Chris@16
|
124 */
|
Chris@16
|
125
|
Chris@16
|
126 //!This exception is thrown when a named object is created
|
Chris@16
|
127 //!in "open_only" mode and the resource was not already created
|
Chris@16
|
128 /*
|
Chris@16
|
129 class not_previously_created : public interprocess_exception
|
Chris@16
|
130 {
|
Chris@16
|
131 public:
|
Chris@16
|
132 virtual const char* what() const throw()
|
Chris@16
|
133 { return "boost::interprocess::not_previously_created"; }
|
Chris@16
|
134 };
|
Chris@16
|
135 */
|
Chris@16
|
136
|
Chris@16
|
137 //!This exception is thrown when a memory request can't be
|
Chris@16
|
138 //!fulfilled.
|
Chris@16
|
139 class bad_alloc : public interprocess_exception
|
Chris@16
|
140 {
|
Chris@16
|
141 public:
|
Chris@16
|
142 bad_alloc() : interprocess_exception("::boost::interprocess::bad_alloc"){}
|
Chris@16
|
143 virtual const char* what() const throw()
|
Chris@16
|
144 { return "boost::interprocess::bad_alloc"; }
|
Chris@16
|
145 };
|
Chris@16
|
146
|
Chris@16
|
147 } // namespace interprocess {
|
Chris@16
|
148
|
Chris@16
|
149 } // namespace boost
|
Chris@16
|
150
|
Chris@16
|
151 #include <boost/interprocess/detail/config_end.hpp>
|
Chris@16
|
152
|
Chris@16
|
153 #endif // BOOST_INTERPROCESS_EXCEPTIONS_HPP
|