]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | #ifndef BOOST_SYSTEM_SYSTEM_ERROR_HPP |
2 | #define BOOST_SYSTEM_SYSTEM_ERROR_HPP | |
7c673cae | 3 | |
1e59de90 TL |
4 | // Copyright Beman Dawes 2006 |
5 | // Copyright Peter Dimov 2021 | |
6 | // Distributed under the Boost Software License, Version 1.0. | |
7 | // https://www.boost.org/LICENSE_1_0.txt | |
8 | ||
9 | #include <boost/system/errc.hpp> | |
10 | #include <boost/system/detail/error_code.hpp> | |
7c673cae FG |
11 | #include <string> |
12 | #include <stdexcept> | |
13 | #include <cassert> | |
7c673cae FG |
14 | |
15 | namespace boost | |
16 | { | |
1e59de90 TL |
17 | namespace system |
18 | { | |
7c673cae | 19 | |
1e59de90 TL |
20 | class BOOST_SYMBOL_VISIBLE system_error: public std::runtime_error |
21 | { | |
22 | private: | |
7c673cae | 23 | |
1e59de90 | 24 | error_code code_; |
7c673cae | 25 | |
1e59de90 | 26 | public: |
7c673cae | 27 | |
1e59de90 TL |
28 | explicit system_error( error_code const & ec ): |
29 | std::runtime_error( ec.what() ), code_( ec ) {} | |
7c673cae | 30 | |
1e59de90 TL |
31 | system_error( error_code const & ec, std::string const & prefix ): |
32 | std::runtime_error( prefix + ": " + ec.what() ), code_( ec ) {} | |
7c673cae | 33 | |
1e59de90 TL |
34 | system_error( error_code const & ec, char const * prefix ): |
35 | std::runtime_error( std::string( prefix ) + ": " + ec.what() ), code_( ec ) {} | |
7c673cae | 36 | |
1e59de90 TL |
37 | system_error( int ev, error_category const & ecat ): |
38 | std::runtime_error( error_code( ev, ecat ).what() ), code_( ev, ecat ) {} | |
7c673cae | 39 | |
1e59de90 TL |
40 | system_error( int ev, error_category const & ecat, std::string const & prefix ): |
41 | std::runtime_error( prefix + ": " + error_code( ev, ecat ).what() ), code_( ev, ecat ) {} | |
7c673cae | 42 | |
1e59de90 TL |
43 | system_error( int ev, error_category const & ecat, char const * prefix ): |
44 | std::runtime_error( std::string( prefix ) + ": " + error_code( ev, ecat ).what() ), code_( ev, ecat ) {} | |
7c673cae | 45 | |
1e59de90 | 46 | error_code code() const BOOST_NOEXCEPT |
7c673cae | 47 | { |
1e59de90 | 48 | return code_; |
7c673cae | 49 | } |
1e59de90 | 50 | }; |
7c673cae | 51 | |
1e59de90 | 52 | } // namespace system |
7c673cae FG |
53 | } // namespace boost |
54 | ||
b32b8144 | 55 | #endif // BOOST_SYSTEM_SYSTEM_ERROR_HPP |