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
15namespace boost
16{
17namespace system
18{
19
20class BOOST_SYMBOL_VISIBLE system_error: public std::runtime_error
21{
22private:
23
24 error_code code_;
25
26public:
27
28 explicit system_error( error_code const & ec ):
29 std::runtime_error( ec.what() ), code_( ec ) {}
30
31 system_error( error_code const & ec, std::string const & prefix ):
32 std::runtime_error( prefix + ": " + ec.what() ), code_( ec ) {}
33
34 system_error( error_code const & ec, char const * prefix ):
35 std::runtime_error( std::string( prefix ) + ": " + ec.what() ), code_( ec ) {}
36
37 system_error( int ev, error_category const & ecat ):
38 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 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 std::runtime_error( std::string( prefix ) + ": " + error_code( ev, ecat ).what() ), code_( ev, ecat ) {}
45
46 error_code code() const noexcept
47 {
48 return code_;
49 }
50};
51
52} // namespace system
53} // namespace boost
54
55#endif // BOOST_SYSTEM_SYSTEM_ERROR_HPP
56

source code of boost/libs/system/include/boost/system/system_error.hpp