1
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)
6
7#ifndef BOOST_COROUTINES_EXCEPTIONS_H
8#define BOOST_COROUTINES_EXCEPTIONS_H
9
10#include <stdexcept>
11#include <string>
12
13#include <boost/config.hpp>
14#include <boost/core/scoped_enum.hpp>
15#include <boost/system/error_code.hpp>
16#include <boost/system/system_error.hpp>
17#include <boost/type_traits/integral_constant.hpp>
18
19#include <boost/coroutine/detail/config.hpp>
20
21#ifdef BOOST_HAS_ABI_HEADERS
22# include BOOST_ABI_PREFIX
23#endif
24
25namespace boost {
26namespace coroutines {
27namespace detail {
28
29struct forced_unwind {};
30
31}
32
33BOOST_SCOPED_ENUM_DECLARE_BEGIN(coroutine_errc)
34{
35 no_data = 1
36}
37BOOST_SCOPED_ENUM_DECLARE_END(coroutine_errc)
38
39BOOST_COROUTINES_DECL
40system::error_category const& coroutine_category() BOOST_NOEXCEPT;
41
42}
43
44namespace system {
45
46template<>
47struct is_error_code_enum< coroutines::coroutine_errc > : public true_type
48{};
49
50#ifdef BOOST_NO_CXX11_SCOPED_ENUMS
51template<>
52struct is_error_code_enum< coroutines::coroutine_errc::enum_type > : public true_type
53{};
54#endif
55
56inline
57error_code make_error_code( coroutines::coroutine_errc e) //BOOST_NOEXCEPT
58{
59 return error_code( underlying_cast< int >( v: e), coroutines::coroutine_category() );
60}
61
62inline
63error_condition make_error_condition( coroutines::coroutine_errc e) //BOOST_NOEXCEPT
64{
65 return error_condition( underlying_cast< int >( v: e), coroutines::coroutine_category() );
66}
67
68}
69
70namespace coroutines {
71
72class coroutine_error : public std::logic_error
73{
74private:
75 system::error_code ec_;
76
77public:
78 coroutine_error( system::error_code ec) :
79 logic_error( ec.message() ),
80 ec_( ec)
81 {}
82
83 system::error_code const& code() const BOOST_NOEXCEPT
84 { return ec_; }
85};
86
87class invalid_result : public coroutine_error
88{
89public:
90 invalid_result() :
91 coroutine_error(
92 system::make_error_code(
93 e: coroutine_errc::no_data) )
94 {}
95};
96
97}}
98
99#ifdef BOOST_HAS_ABI_HEADERS
100# include BOOST_ABI_SUFFIX
101#endif
102
103#endif // BOOST_COROUTINES_EXCEPTIONS_H
104

source code of boost/libs/coroutine/include/boost/coroutine/exceptions.hpp