1 //  (C) Copyright 2008-10 Anthony Williams
2 //  (C) Copyright 2011-2015 Vicente J. Botet Escriba
3 //
4 //  Distributed under the Boost Software License, Version 1.0. (See
5 //  accompanying file LICENSE_1_0.txt or copy at
6 //  http://www.boost.org/LICENSE_1_0.txt)
7 
8 #ifndef BOOST_THREAD_FUTURES_FUTURE_ERROR_HPP
9 #define BOOST_THREAD_FUTURES_FUTURE_ERROR_HPP
10 
11 #include <boost/thread/detail/config.hpp>
12 
13 #include <boost/thread/futures/future_error_code.hpp>
14 #include <boost/system/error_code.hpp>
15 
16 #include <stdexcept>
17 
18 namespace boost
19 {
20   class BOOST_SYMBOL_VISIBLE future_error
21       : public std::logic_error
22   {
23       system::error_code ec_;
24   public:
future_error(system::error_code ec)25       future_error(system::error_code ec)
26       : logic_error(ec.message()),
27         ec_(ec)
28       {
29       }
30 
code() const31       const system::error_code& code() const BOOST_NOEXCEPT
32       {
33         return ec_;
34       }
35   };
36 
37     class BOOST_SYMBOL_VISIBLE future_uninitialized:
38         public future_error
39     {
40     public:
future_uninitialized()41         future_uninitialized() :
42           future_error(system::make_error_code(future_errc::no_state))
43         {}
44     };
45     class BOOST_SYMBOL_VISIBLE broken_promise:
46         public future_error
47     {
48     public:
broken_promise()49         broken_promise():
50           future_error(system::make_error_code(future_errc::broken_promise))
51         {}
52     };
53     class BOOST_SYMBOL_VISIBLE future_already_retrieved:
54         public future_error
55     {
56     public:
future_already_retrieved()57         future_already_retrieved():
58           future_error(system::make_error_code(future_errc::future_already_retrieved))
59         {}
60     };
61     class BOOST_SYMBOL_VISIBLE promise_already_satisfied:
62         public future_error
63     {
64     public:
promise_already_satisfied()65         promise_already_satisfied():
66           future_error(system::make_error_code(future_errc::promise_already_satisfied))
67         {}
68     };
69 
70     class BOOST_SYMBOL_VISIBLE task_already_started:
71         public future_error
72     {
73     public:
task_already_started()74         task_already_started():
75         future_error(system::make_error_code(future_errc::promise_already_satisfied))
76         {}
77     };
78 
79     class BOOST_SYMBOL_VISIBLE task_moved:
80         public future_error
81     {
82     public:
task_moved()83         task_moved():
84           future_error(system::make_error_code(future_errc::no_state))
85         {}
86     };
87 
88     class promise_moved:
89         public future_error
90     {
91     public:
promise_moved()92           promise_moved():
93           future_error(system::make_error_code(future_errc::no_state))
94         {}
95     };
96 }
97 
98 #endif // header
99