exceptions.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. // Copyright (C) 2001-2003
  2. // William E. Kempf
  3. // Copyright (C) 2007-9 Anthony Williams
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. #ifndef BOOST_THREAD_EXCEPTIONS_PDM070801_H
  8. #define BOOST_THREAD_EXCEPTIONS_PDM070801_H
  9. #include <boost/thread/detail/config.hpp>
  10. // pdm: Sorry, but this class is used all over the place & I end up
  11. // with recursive headers if I don't separate it
  12. // wek: Not sure why recursive headers would cause compilation problems
  13. // given the include guards, but regardless it makes sense to
  14. // seperate this out any way.
  15. #include <string>
  16. #include <stdexcept>
  17. #include <boost/config/abi_prefix.hpp>
  18. namespace boost
  19. {
  20. class thread_interrupted
  21. {};
  22. class thread_exception:
  23. public std::exception
  24. {
  25. protected:
  26. thread_exception():
  27. m_sys_err(0)
  28. {}
  29. thread_exception(int sys_err_code):
  30. m_sys_err(sys_err_code)
  31. {}
  32. public:
  33. ~thread_exception() throw()
  34. {}
  35. int native_error() const
  36. {
  37. return m_sys_err;
  38. }
  39. private:
  40. int m_sys_err;
  41. };
  42. class condition_error:
  43. public std::exception
  44. {
  45. public:
  46. const char* what() const throw()
  47. {
  48. return "Condition error";
  49. }
  50. };
  51. class lock_error:
  52. public thread_exception
  53. {
  54. public:
  55. lock_error()
  56. {}
  57. lock_error(int sys_err_code):
  58. thread_exception(sys_err_code)
  59. {}
  60. ~lock_error() throw()
  61. {}
  62. virtual const char* what() const throw()
  63. {
  64. return "boost::lock_error";
  65. }
  66. };
  67. class thread_resource_error:
  68. public thread_exception
  69. {
  70. public:
  71. thread_resource_error()
  72. {}
  73. thread_resource_error(int sys_err_code):
  74. thread_exception(sys_err_code)
  75. {}
  76. ~thread_resource_error() throw()
  77. {}
  78. virtual const char* what() const throw()
  79. {
  80. return "boost::thread_resource_error";
  81. }
  82. };
  83. class unsupported_thread_option:
  84. public thread_exception
  85. {
  86. public:
  87. unsupported_thread_option()
  88. {}
  89. unsupported_thread_option(int sys_err_code):
  90. thread_exception(sys_err_code)
  91. {}
  92. ~unsupported_thread_option() throw()
  93. {}
  94. virtual const char* what() const throw()
  95. {
  96. return "boost::unsupported_thread_option";
  97. }
  98. };
  99. class invalid_thread_argument:
  100. public thread_exception
  101. {
  102. public:
  103. invalid_thread_argument()
  104. {}
  105. invalid_thread_argument(int sys_err_code):
  106. thread_exception(sys_err_code)
  107. {}
  108. ~invalid_thread_argument() throw()
  109. {}
  110. virtual const char* what() const throw()
  111. {
  112. return "boost::invalid_thread_argument";
  113. }
  114. };
  115. class thread_permission_error:
  116. public thread_exception
  117. {
  118. public:
  119. thread_permission_error()
  120. {}
  121. thread_permission_error(int sys_err_code):
  122. thread_exception(sys_err_code)
  123. {}
  124. ~thread_permission_error() throw()
  125. {}
  126. virtual const char* what() const throw()
  127. {
  128. return "boost::thread_permission_error";
  129. }
  130. };
  131. } // namespace boost
  132. #include <boost/config/abi_suffix.hpp>
  133. #endif