File indexing completed on 2025-07-11 08:05:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_BEAST_IMPL_ERROR_IPP
0011 #define BOOST_BEAST_IMPL_ERROR_IPP
0012
0013 #include <boost/beast/core/error.hpp>
0014
0015 namespace boost {
0016 namespace beast {
0017
0018 namespace detail {
0019
0020 class error_codes : public error_category
0021 {
0022 public:
0023 const char*
0024 name() const noexcept override
0025 {
0026 return "boost.beast";
0027 }
0028
0029 error_codes() : error_category(0x002f6e94401c6e8bu) {}
0030
0031 BOOST_BEAST_DECL
0032 char const*
0033 message(int ev, char*, std::size_t) const noexcept override
0034 {
0035 switch(static_cast<error>(ev))
0036 {
0037 default:
0038 case error::timeout: return
0039 "The socket was closed due to a timeout";
0040 }
0041 }
0042
0043 BOOST_BEAST_DECL
0044 std::string
0045 message(int ev) const override
0046 {
0047 return message(ev, nullptr, 0);
0048 }
0049
0050 BOOST_BEAST_DECL
0051 error_condition
0052 default_error_condition(int ev) const noexcept override
0053 {
0054 switch(static_cast<error>(ev))
0055 {
0056 default:
0057
0058 case error::timeout:
0059 return condition::timeout;
0060 }
0061 }
0062 };
0063
0064 class error_conditions : public error_category
0065 {
0066 public:
0067 BOOST_BEAST_DECL
0068 const char*
0069 name() const noexcept override
0070 {
0071 return "boost.beast";
0072 }
0073
0074 error_conditions() : error_category(0x3dd0b0ce843c5b10u) {}
0075
0076 BOOST_BEAST_DECL
0077 char const*
0078 message(int cv, char*, std::size_t) const noexcept override
0079 {
0080 switch(static_cast<condition>(cv))
0081 {
0082 default:
0083 case condition::timeout:
0084 return "The operation timed out";
0085 }
0086 }
0087
0088 BOOST_BEAST_DECL
0089 std::string
0090 message(int cv) const override
0091 {
0092 return message(cv, nullptr, 0);
0093 }
0094 };
0095
0096 }
0097
0098 error_code
0099 make_error_code(error e)
0100 {
0101 static detail::error_codes const cat{};
0102 return error_code{static_cast<
0103 std::underlying_type<error>::type>(e), cat};
0104 }
0105
0106 error_condition
0107 make_error_condition(condition c)
0108 {
0109 static detail::error_conditions const cat{};
0110 return error_condition{static_cast<
0111 std::underlying_type<condition>::type>(c), cat};
0112 }
0113
0114 }
0115 }
0116
0117 #endif