LCOV - code coverage report
Current view: top level - http_proto/impl - error.ipp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 40 42 95.2 %
Date: 2023-01-15 07:18:31 Functions: 5 5 100.0 %

          Line data    Source code
       1             : //
       2             : // Copyright (c) 2021 Vinnie Falco (vinnie dot falco at gmail dot com)
       3             : //
       4             : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       5             : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       6             : //
       7             : // Official repository: https://github.com/CPPAlliance/http_proto
       8             : //
       9             : 
      10             : #ifndef BOOST_HTTP_PROTO_IMPL_ERROR_IPP
      11             : #define BOOST_HTTP_PROTO_IMPL_ERROR_IPP
      12             : 
      13             : #include <boost/http_proto/error.hpp>
      14             : #include <boost/assert.hpp>
      15             : #include <type_traits>
      16             : 
      17             : namespace boost {
      18             : namespace http_proto {
      19             : 
      20             : namespace detail {
      21             : 
      22             : static
      23             : error_category const&
      24         116 : get_error_cat() noexcept
      25             : {
      26             :     struct codes : error_category
      27             :     {
      28           5 :         codes() noexcept
      29           5 :             : error_category(
      30           5 :                 0x3663257e7585fbfd)
      31             :         {
      32           5 :         }
      33             :             
      34             :         const char*
      35          27 :         name() const noexcept override
      36             :         {
      37          27 :             return "boost.http.proto";
      38             :         }
      39             : 
      40             :         std::string
      41          27 :         message(int ev) const override
      42             :         {
      43          27 :             switch(static_cast<error>(ev))
      44             :             {
      45           1 :             case error::expect_100_continue: return "expect continue";
      46           1 :             case error::end_of_message: return "end of message";
      47           1 :             case error::end_of_stream: return "end of stream";
      48           1 :             case error::need_data: return "need data";
      49             : 
      50           1 :             case error::bad_connection: return "bad Connection";
      51           1 :             case error::bad_content_length: return "bad Content-Length";
      52           1 :             case error::bad_expect: return "bad Expect";
      53           1 :             case error::bad_field_name: return "bad field name";
      54           1 :             case error::bad_field_value: return "bad field value";
      55           1 :             case error::bad_line_ending: return "bad line ending";
      56           1 :             case error::bad_list: return "bad list";
      57           1 :             case error::bad_method: return "bad method";
      58           1 :             case error::bad_number: return "bad number";
      59           1 :             case error::bad_version: return "bad version";
      60           1 :             case error::bad_reason: return "bad reason-phrase";
      61           1 :             case error::bad_request_target: return "bad request-target";
      62           1 :             case error::bad_status_code: return "bad status-code";
      63           1 :             case error::bad_status_line: return "bad status-line";
      64           1 :             case error::bad_transfer_encoding: return "bad Transfer-Encoding";
      65           1 :             case error::bad_upgrade: return "bad Upgrade";
      66           1 :             case error::syntax: return "syntax error";
      67             : 
      68           1 :             case error::body_too_large: return "body too large";
      69           1 :             case error::field_too_large: return "field too large";
      70           1 :             case error::header_too_large: return "header too large";
      71           1 :             case error::too_many_fields: return "too many fields";
      72           1 :             case error::numeric_overflow: return "numeric overflow";
      73             : 
      74           1 :             case error::multiple_content_length: return "multiple Content-Length";
      75           0 :             default:
      76           0 :                 return "unknown";
      77             :             }
      78             :         }
      79             :     };
      80         116 :     static codes const t{};
      81         116 :     return t;
      82             : }
      83             : 
      84             : } // detail
      85             : 
      86             : error_code
      87         116 : make_error_code(
      88             :     error ev) noexcept
      89             : {
      90             :     return error_code{static_cast<
      91             :         std::underlying_type<
      92             :             error>::type>(ev),
      93         116 :         detail::get_error_cat()};
      94             : }
      95             : 
      96             : } // http_proto
      97             : } // boost
      98             : 
      99             : #endif

Generated by: LCOV version 1.15