Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:08:24

0001 /* Copyright (c) 2018-2024 Marcelo Zimbres Silva (mzimbres@gmail.com)
0002  *
0003  * Distributed under the Boost Software License, Version 1.0. (See
0004  * accompanying file LICENSE.txt)
0005  */
0006 
0007 #include <boost/redis/error.hpp>
0008 #include <boost/assert.hpp>
0009 
0010 namespace boost::redis {
0011 namespace detail {
0012 
0013 struct error_category_impl : system::error_category {
0014 
0015    virtual ~error_category_impl() = default;
0016 
0017    auto name() const noexcept -> char const* override
0018    {
0019       return "boost.redis";
0020    }
0021 
0022    auto message(int ev) const -> std::string override
0023    {
0024       switch(static_cast<error>(ev)) {
0025      case error::invalid_data_type: return "Invalid resp3 type.";
0026      case error::not_a_number: return "Can't convert string to number (maybe forgot to upgrade to RESP3?).";
0027      case error::exceeeds_max_nested_depth: return "Exceeds the maximum number of nested responses.";
0028      case error::unexpected_bool_value: return "Unexpected bool value.";
0029      case error::empty_field: return "Expected field value is empty.";
0030      case error::expects_resp3_simple_type: return "Expects a resp3 simple type.";
0031      case error::expects_resp3_aggregate: return "Expects resp3 aggregate.";
0032      case error::expects_resp3_map: return "Expects resp3 map.";
0033      case error::expects_resp3_set: return "Expects resp3 set.";
0034      case error::nested_aggregate_not_supported: return "Nested aggregate not_supported.";
0035      case error::resp3_simple_error: return "Got RESP3 simple-error.";
0036      case error::resp3_blob_error: return "Got RESP3 blob-error.";
0037      case error::incompatible_size: return "Aggregate container has incompatible size.";
0038      case error::not_a_double: return "Not a double.";
0039      case error::resp3_null: return "Got RESP3 null.";
0040      case error::not_connected: return "Not connected.";
0041      case error::resolve_timeout: return "Resolve timeout.";
0042      case error::connect_timeout: return "Connect timeout.";
0043      case error::pong_timeout: return "Pong timeout.";
0044      case error::ssl_handshake_timeout: return "SSL handshake timeout.";
0045      case error::sync_receive_push_failed: return "Can't receive server push synchronously without blocking.";
0046      case error::incompatible_node_depth: return "Incompatible node depth.";
0047      case error::resp3_hello: return "RESP3 handshake error (hello command).";
0048      default: BOOST_ASSERT(false); return "Boost.Redis error.";
0049       }
0050    }
0051 };
0052 
0053 auto category() -> system::error_category const&
0054 {
0055   static error_category_impl instance;
0056   return instance;
0057 }
0058 
0059 } // detail
0060 
0061 auto make_error_code(error e) -> system::error_code
0062 {
0063     return system::error_code{static_cast<int>(e), detail::category()};
0064 }
0065 
0066 } // boost::redis::detail