Ticket #6230: 6230_exceptions.diff
File 6230_exceptions.diff, 7.9 KB (added by , 11 years ago) |
---|
-
boost/thread/exceptions.hpp
2 2 // William E. Kempf 3 3 // Copyright (C) 2007-9 Anthony Williams 4 4 // 5 // Distributed under the Boost Software License, Version 1.0. (See accompanying 5 // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 6 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 7 8 8 #ifndef BOOST_THREAD_EXCEPTIONS_PDM070801_H … … 18 18 19 19 #include <string> 20 20 #include <stdexcept> 21 #include <boost/system/system_error.hpp> 22 #include <boost/system/error_code.hpp> 21 23 24 22 25 #include <boost/config/abi_prefix.hpp> 23 26 24 27 namespace boost … … 28 31 {}; 29 32 30 33 class BOOST_SYMBOL_VISIBLE thread_exception: 31 public std::exception 34 public system::system_error 35 //public std::exception 32 36 { 33 protected: 34 thread_exception(): 35 m_sys_err(0) 37 typedef system::system_error base_type; 38 public: 39 thread_exception() 40 : base_type(0,system::system_category()) 36 41 {} 37 38 thread_exception(int sys_err _code):39 m_sys_err(sys_err_code)42 43 thread_exception(int sys_error_code) 44 : base_type(sys_error_code, system::system_category()) 40 45 {} 41 42 46 43 public: 47 thread_exception( int ev, const char * what_arg ) 48 : base_type(system::error_code(ev, system::system_category()), what_arg) 49 { 50 } 51 thread_exception( int ev, const std::string & what_arg ) 52 : base_type(system::error_code(ev, system::system_category()), what_arg) 53 { 54 } 55 44 56 ~thread_exception() throw() 45 57 {} 46 47 58 59 48 60 int native_error() const 49 61 { 50 return m_sys_err;62 return code().value(); 51 63 } 52 53 64 54 private:55 int m_sys_err;56 65 }; 57 66 58 67 class BOOST_SYMBOL_VISIBLE condition_error: 59 public std::exception 68 public system::system_error 69 //public std::exception 60 70 { 71 typedef system::system_error base_type; 61 72 public: 62 const char* what() const throw() 63 { 64 return "Condition error"; 65 } 73 condition_error() 74 : base_type(system::error_code(0, system::system_category()), "Condition error") 75 {} 76 condition_error( int ev ) 77 : base_type(system::error_code(ev, system::system_category()), "Condition error") 78 { 79 } 80 condition_error( int ev, const char * what_arg ) 81 : base_type(system::error_code(ev, system::system_category()), what_arg) 82 { 83 } 84 condition_error( int ev, const std::string & what_arg ) 85 : base_type(system::error_code(ev, system::system_category()), what_arg) 86 { 87 } 66 88 }; 67 68 89 90 69 91 class BOOST_SYMBOL_VISIBLE lock_error: 70 92 public thread_exception 71 93 { 94 typedef thread_exception base_type; 72 95 public: 73 96 lock_error() 97 : base_type(0, "boost::lock_error") 74 98 {} 75 76 lock_error(int sys_err_code): 77 thread_exception(sys_err_code) 78 {} 79 99 100 lock_error( int ev ) 101 : base_type(ev, "boost::lock_error") 102 { 103 } 104 lock_error( int ev, const char * what_arg ) 105 : base_type(ev, what_arg) 106 { 107 } 108 lock_error( int ev, const std::string & what_arg ) 109 : base_type(ev, what_arg) 110 { 111 } 112 80 113 ~lock_error() throw() 81 114 {} 82 83 115 84 virtual const char* what() const throw()85 {86 return "boost::lock_error";87 }88 116 }; 89 117 90 118 class BOOST_SYMBOL_VISIBLE thread_resource_error: 91 119 public thread_exception 92 120 { 121 typedef thread_exception base_type; 93 122 public: 94 thread_resource_error() 95 {} 96 97 thread_resource_error(int sys_err_code): 98 thread_exception(sys_err_code) 99 {} 100 123 thread_resource_error() 124 : base_type(system::errc::resource_unavailable_try_again, "boost::thread_resource_error") 125 {} 126 127 thread_resource_error( int ev ) 128 : base_type(ev, "boost::thread_resource_error") 129 { 130 } 131 thread_resource_error( int ev, const char * what_arg ) 132 : base_type(ev, what_arg) 133 { 134 } 135 thread_resource_error( int ev, const std::string & what_arg ) 136 : base_type(ev, what_arg) 137 { 138 } 139 140 101 141 ~thread_resource_error() throw() 102 142 {} 103 104 143 105 virtual const char* what() const throw()106 {107 return "boost::thread_resource_error";108 }109 110 144 }; 111 145 112 146 class BOOST_SYMBOL_VISIBLE unsupported_thread_option: 113 147 public thread_exception 114 148 { 149 typedef thread_exception base_type; 115 150 public: 116 unsupported_thread_option() 117 {} 118 119 unsupported_thread_option(int sys_err_code): 120 thread_exception(sys_err_code) 121 {} 122 123 ~unsupported_thread_option() throw() 124 {} 125 151 unsupported_thread_option() 152 : base_type(system::errc::invalid_argument, "boost::unsupported_thread_option") 153 {} 126 154 127 virtual const char* what() const throw() 128 { 129 return "boost::unsupported_thread_option"; 130 } 131 155 unsupported_thread_option( int ev ) 156 : base_type(ev, "boost::unsupported_thread_option") 157 { 158 } 159 unsupported_thread_option( int ev, const char * what_arg ) 160 : base_type(ev, what_arg) 161 { 162 } 163 unsupported_thread_option( int ev, const std::string & what_arg ) 164 : base_type(ev, what_arg) 165 { 166 } 167 132 168 }; 133 169 134 170 class BOOST_SYMBOL_VISIBLE invalid_thread_argument: 135 171 public thread_exception 136 172 { 173 typedef thread_exception base_type; 137 174 public: 138 175 invalid_thread_argument() 176 : base_type(system::errc::invalid_argument, "boost::invalid_thread_argument") 139 177 {} 140 141 invalid_thread_argument(int sys_err_code):142 thread_exception(sys_err_code)143 {}144 145 ~invalid_thread_argument() throw()146 {}147 148 178 149 virtual const char* what() const throw() 179 invalid_thread_argument( int ev ) 180 : base_type(ev, "boost::invalid_thread_argument") 150 181 { 151 return "boost::invalid_thread_argument";152 182 } 153 183 invalid_thread_argument( int ev, const char * what_arg ) 184 : base_type(ev, what_arg) 185 { 186 } 187 invalid_thread_argument( int ev, const std::string & what_arg ) 188 : base_type(ev, what_arg) 189 { 190 } 191 154 192 }; 155 193 156 194 class BOOST_SYMBOL_VISIBLE thread_permission_error: 157 195 public thread_exception 158 196 { 197 typedef thread_exception base_type; 159 198 public: 160 thread_permission_error() 161 {} 162 163 thread_permission_error(int sys_err_code): 164 thread_exception(sys_err_code) 165 {} 166 167 ~thread_permission_error() throw() 168 {} 169 199 thread_permission_error() 200 : base_type(system::errc::permission_denied, "boost::thread_permission_error") 201 {} 170 202 171 virtual const char* what() const throw() 172 { 173 return "boost::thread_permission_error"; 174 } 175 203 thread_permission_error( int ev ) 204 : base_type(ev, "boost::thread_permission_error") 205 { 206 } 207 thread_permission_error( int ev, const char * what_arg ) 208 : base_type(ev, what_arg) 209 { 210 } 211 thread_permission_error( int ev, const std::string & what_arg ) 212 : base_type(ev, what_arg) 213 { 214 } 215 176 216 }; 177 217 178 218 } // namespace boost