/src/boost/boost/system/system_error.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef BOOST_SYSTEM_SYSTEM_ERROR_HPP |
2 | | #define BOOST_SYSTEM_SYSTEM_ERROR_HPP |
3 | | |
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> |
11 | | #include <string> |
12 | | #include <stdexcept> |
13 | | #include <cassert> |
14 | | |
15 | | namespace boost |
16 | | { |
17 | | namespace system |
18 | | { |
19 | | |
20 | | class BOOST_SYMBOL_VISIBLE system_error: public std::runtime_error |
21 | | { |
22 | | private: |
23 | | |
24 | | error_code code_; |
25 | | |
26 | | public: |
27 | | |
28 | | explicit system_error( error_code const & ec ): |
29 | 0 | std::runtime_error( ec.what() ), code_( ec ) {} |
30 | | |
31 | | system_error( error_code const & ec, std::string const & prefix ): |
32 | 0 | std::runtime_error( prefix + ": " + ec.what() ), code_( ec ) {} |
33 | | |
34 | | system_error( error_code const & ec, char const * prefix ): |
35 | 0 | std::runtime_error( std::string( prefix ) + ": " + ec.what() ), code_( ec ) {} |
36 | | |
37 | | system_error( int ev, error_category const & ecat ): |
38 | 0 | std::runtime_error( error_code( ev, ecat ).what() ), code_( ev, ecat ) {} |
39 | | |
40 | | system_error( int ev, error_category const & ecat, std::string const & prefix ): |
41 | 0 | std::runtime_error( prefix + ": " + error_code( ev, ecat ).what() ), code_( ev, ecat ) {} |
42 | | |
43 | | system_error( int ev, error_category const & ecat, char const * prefix ): |
44 | 0 | std::runtime_error( std::string( prefix ) + ": " + error_code( ev, ecat ).what() ), code_( ev, ecat ) {} |
45 | | |
46 | | error_code code() const noexcept |
47 | 0 | { |
48 | 0 | return code_; |
49 | 0 | } |
50 | | }; |
51 | | |
52 | | } // namespace system |
53 | | } // namespace boost |
54 | | |
55 | | #endif // BOOST_SYSTEM_SYSTEM_ERROR_HPP |