1 //  Copyright (c) 2007-2014 Hartmut Kaiser
2 //  Copyright (c) 2011      Bryce Lelbach
3 //
4 //  Distributed under the Boost Software License, Version 1.0. (See accompanying
5 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 
7 /// \file exception_fwd.hpp
8 
9 #ifndef HPX_EXCEPTION_FWD_HPP
10 #define HPX_EXCEPTION_FWD_HPP
11 
12 #include <hpx/config.hpp>
13 #include <hpx/error.hpp>
14 
15 /// \cond NOINTERNAL
16 namespace boost
17 {
18     class exception_ptr;
19 }
20 /// \endcond
21 
22 namespace hpx
23 {
24     /// \cond NOINTERNAL
25     // forward declaration
26     class error_code;
27 
28     class HPX_EXCEPTION_EXPORT exception;
29 
30     struct HPX_EXCEPTION_EXPORT thread_interrupted;
31     /// \endcond
32 
33     ///////////////////////////////////////////////////////////////////////////
34     /// \brief Encode error category for new error_code.
35     enum throwmode
36     {
37         plain = 0,
38         rethrow = 1,
39         lightweight = 0x80, // do not generate an exception for this error_code
40         /// \cond NODETAIL
41         lightweight_rethrow = lightweight | rethrow
42         /// \endcond
43     };
44 
45     ///////////////////////////////////////////////////////////////////////////
46     /// \brief Predefined error_code object used as "throw on error" tag.
47     ///
48     /// The predefined hpx::error_code object \a hpx::throws is supplied for use as
49     /// a "throw on error" tag.
50     ///
51     /// Functions that specify an argument in the form 'error_code& ec=throws'
52     /// (with appropriate namespace qualifiers), have the following error
53     /// handling semantics:
54     ///
55     /// If &ec != &throws and an error occurred: ec.value() returns the
56     /// implementation specific error number for the particular error that
57     /// occurred and ec.category() returns the error_category for ec.value().
58     ///
59     /// If &ec != &throws and an error did not occur, ec.clear().
60     ///
61     /// If an error occurs and &ec == &throws, the function throws an exception
62     /// of type \a hpx::exception or of a type derived from it. The exception's
63     /// \a get_errorcode() member function returns a reference to an
64     /// \a hpx::error_code object with the behavior as specified above.
65     ///
66     HPX_EXCEPTION_EXPORT extern error_code throws;
67 }
68 
69 #include <hpx/throw_exception.hpp>
70 
71 #endif
72