exceptions.hpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. // Copyright (C) 2001-2003
  2. // William E. Kempf
  3. // Copyright (C) 2007-9 Anthony Williams
  4. // (C) Copyright 2011-2012 Vicente J. Botet Escriba
  5. //
  6. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  7. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef BOOST_THREAD_EXCEPTIONS_PDM070801_H
  9. #define BOOST_THREAD_EXCEPTIONS_PDM070801_H
  10. #include <boost/thread/detail/config.hpp>
  11. // pdm: Sorry, but this class is used all over the place & I end up
  12. // with recursive headers if I don't separate it
  13. // wek: Not sure why recursive headers would cause compilation problems
  14. // given the include guards, but regardless it makes sense to
  15. // seperate this out any way.
  16. #include <string>
  17. #include <stdexcept>
  18. #include <boost/system/system_error.hpp>
  19. #include <boost/system/error_code.hpp>
  20. #include <boost/config/abi_prefix.hpp>
  21. namespace boost
  22. {
  23. #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
  24. class BOOST_SYMBOL_VISIBLE thread_interrupted
  25. {};
  26. #endif
  27. class BOOST_SYMBOL_VISIBLE thread_exception:
  28. public system::system_error
  29. //public std::exception
  30. {
  31. typedef system::system_error base_type;
  32. public:
  33. thread_exception()
  34. : base_type(0,system::generic_category())
  35. {}
  36. thread_exception(int sys_error_code)
  37. : base_type(sys_error_code, system::generic_category())
  38. {}
  39. thread_exception( int ev, const char * what_arg )
  40. : base_type(system::error_code(ev, system::generic_category()), what_arg)
  41. {
  42. }
  43. thread_exception( int ev, const std::string & what_arg )
  44. : base_type(system::error_code(ev, system::generic_category()), what_arg)
  45. {
  46. }
  47. ~thread_exception() BOOST_NOEXCEPT_OR_NOTHROW
  48. {}
  49. int native_error() const
  50. {
  51. return code().value();
  52. }
  53. };
  54. class BOOST_SYMBOL_VISIBLE condition_error:
  55. public system::system_error
  56. //public std::exception
  57. {
  58. typedef system::system_error base_type;
  59. public:
  60. condition_error()
  61. : base_type(system::error_code(0, system::generic_category()), "Condition error")
  62. {}
  63. condition_error( int ev )
  64. : base_type(system::error_code(ev, system::generic_category()), "Condition error")
  65. {
  66. }
  67. condition_error( int ev, const char * what_arg )
  68. : base_type(system::error_code(ev, system::generic_category()), what_arg)
  69. {
  70. }
  71. condition_error( int ev, const std::string & what_arg )
  72. : base_type(system::error_code(ev, system::generic_category()), what_arg)
  73. {
  74. }
  75. };
  76. class BOOST_SYMBOL_VISIBLE lock_error:
  77. public thread_exception
  78. {
  79. typedef thread_exception base_type;
  80. public:
  81. lock_error()
  82. : base_type(0, "boost::lock_error")
  83. {}
  84. lock_error( int ev )
  85. : base_type(ev, "boost::lock_error")
  86. {
  87. }
  88. lock_error( int ev, const char * what_arg )
  89. : base_type(ev, what_arg)
  90. {
  91. }
  92. lock_error( int ev, const std::string & what_arg )
  93. : base_type(ev, what_arg)
  94. {
  95. }
  96. ~lock_error() BOOST_NOEXCEPT_OR_NOTHROW
  97. {}
  98. };
  99. class BOOST_SYMBOL_VISIBLE thread_resource_error:
  100. public thread_exception
  101. {
  102. typedef thread_exception base_type;
  103. public:
  104. thread_resource_error()
  105. : base_type(static_cast<int>(system::errc::resource_unavailable_try_again), "boost::thread_resource_error")
  106. {}
  107. thread_resource_error( int ev )
  108. : base_type(ev, "boost::thread_resource_error")
  109. {
  110. }
  111. thread_resource_error( int ev, const char * what_arg )
  112. : base_type(ev, what_arg)
  113. {
  114. }
  115. thread_resource_error( int ev, const std::string & what_arg )
  116. : base_type(ev, what_arg)
  117. {
  118. }
  119. ~thread_resource_error() BOOST_NOEXCEPT_OR_NOTHROW
  120. {}
  121. };
  122. class BOOST_SYMBOL_VISIBLE unsupported_thread_option:
  123. public thread_exception
  124. {
  125. typedef thread_exception base_type;
  126. public:
  127. unsupported_thread_option()
  128. : base_type(static_cast<int>(system::errc::invalid_argument), "boost::unsupported_thread_option")
  129. {}
  130. unsupported_thread_option( int ev )
  131. : base_type(ev, "boost::unsupported_thread_option")
  132. {
  133. }
  134. unsupported_thread_option( int ev, const char * what_arg )
  135. : base_type(ev, what_arg)
  136. {
  137. }
  138. unsupported_thread_option( int ev, const std::string & what_arg )
  139. : base_type(ev, what_arg)
  140. {
  141. }
  142. };
  143. class BOOST_SYMBOL_VISIBLE invalid_thread_argument:
  144. public thread_exception
  145. {
  146. typedef thread_exception base_type;
  147. public:
  148. invalid_thread_argument()
  149. : base_type(static_cast<int>(system::errc::invalid_argument), "boost::invalid_thread_argument")
  150. {}
  151. invalid_thread_argument( int ev )
  152. : base_type(ev, "boost::invalid_thread_argument")
  153. {
  154. }
  155. invalid_thread_argument( int ev, const char * what_arg )
  156. : base_type(ev, what_arg)
  157. {
  158. }
  159. invalid_thread_argument( int ev, const std::string & what_arg )
  160. : base_type(ev, what_arg)
  161. {
  162. }
  163. };
  164. class BOOST_SYMBOL_VISIBLE thread_permission_error:
  165. public thread_exception
  166. {
  167. typedef thread_exception base_type;
  168. public:
  169. thread_permission_error()
  170. : base_type(static_cast<int>(system::errc::permission_denied), "boost::thread_permission_error")
  171. {}
  172. thread_permission_error( int ev )
  173. : base_type(ev, "boost::thread_permission_error")
  174. {
  175. }
  176. thread_permission_error( int ev, const char * what_arg )
  177. : base_type(ev, what_arg)
  178. {
  179. }
  180. thread_permission_error( int ev, const std::string & what_arg )
  181. : base_type(ev, what_arg)
  182. {
  183. }
  184. };
  185. } // namespace boost
  186. #include <boost/config/abi_suffix.hpp>
  187. #endif