2 // Copyright Oliver Kowalke 2009.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_COROUTINES_EXCEPTIONS_H
8 #define BOOST_COROUTINES_EXCEPTIONS_H
13 #include <boost/config.hpp>
14 #include <boost/detail/scoped_enum_emulation.hpp>
15 #include <boost/system/error_code.hpp>
16 #include <boost/system/system_error.hpp>
17 #include <boost/type_traits/integral_constant.hpp>
19 #include <boost/coroutine/detail/config.hpp>
21 #ifdef BOOST_HAS_ABI_HEADERS
22 # include BOOST_ABI_PREFIX
26 namespace coroutines {
29 struct forced_unwind {};
33 BOOST_SCOPED_ENUM_DECLARE_BEGIN(coroutine_errc)
37 BOOST_SCOPED_ENUM_DECLARE_END(coroutine_errc)
40 system::error_category const& coroutine_category() BOOST_NOEXCEPT;
47 struct is_error_code_enum< coroutines::coroutine_errc > : public true_type
50 #ifdef BOOST_NO_CXX11_SCOPED_ENUMS
52 struct is_error_code_enum< coroutines::coroutine_errc::enum_type > : public true_type
57 error_code make_error_code( coroutines::coroutine_errc e) //BOOST_NOEXCEPT
59 return error_code( underlying_cast< int >( e), coroutines::coroutine_category() );
63 error_condition make_error_condition( coroutines::coroutine_errc e) //BOOST_NOEXCEPT
65 return error_condition( underlying_cast< int >( e), coroutines::coroutine_category() );
70 namespace coroutines {
72 class coroutine_error : public std::logic_error
75 system::error_code ec_;
78 coroutine_error( system::error_code ec) :
79 logic_error( ec.message() ),
83 system::error_code const& code() const BOOST_NOEXCEPT
87 class invalid_result : public coroutine_error
92 system::make_error_code(
93 coroutine_errc::no_data) )
99 #ifdef BOOST_HAS_ABI_HEADERS
100 # include BOOST_ABI_SUFFIX
103 #endif // BOOST_COROUTINES_EXCEPTIONS_H