LCOV - code coverage report
Current view: top level - boost/capy - error.hpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 3 3
Test Date: 2026-01-30 23:43:15 Functions: 100.0 % 1 1

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.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/capy
       8              : //
       9              : 
      10              : #ifndef BOOST_CAPY_ERROR_HPP
      11              : #define BOOST_CAPY_ERROR_HPP
      12              : 
      13              : #include <boost/capy/detail/config.hpp>
      14              : #include <system_error>
      15              : 
      16              : namespace boost {
      17              : namespace capy {
      18              : 
      19              : /** Error codes returned from algorithms and operations.
      20              : 
      21              :     Return `error::eof` when originating an eof error.
      22              :     Check `ec == cond::eof` for portable comparison.
      23              : 
      24              :     Return `error::canceled` when originating a cancellation error.
      25              :     Check `ec == cond::canceled` for portable comparison.
      26              : 
      27              :     Return `error::stream_truncated` when peer closes without TLS shutdown.
      28              :     Check `ec == cond::stream_truncated` for portable comparison.
      29              : */
      30              : enum class error
      31              : {
      32              :     eof = 1,
      33              :     canceled,
      34              :     test_failure,
      35              :     stream_truncated,
      36              :     not_found
      37              : };
      38              : 
      39              : //-----------------------------------------------
      40              : 
      41              : } // capy
      42              : } // boost
      43              : 
      44              : namespace std {
      45              : template<>
      46              : struct is_error_code_enum<
      47              :     ::boost::capy::error>
      48              :     : std::true_type {};
      49              : } // std
      50              : 
      51              : namespace boost {
      52              : namespace capy {
      53              : 
      54              : //-----------------------------------------------
      55              : 
      56              : namespace detail {
      57              :  
      58              : struct BOOST_CAPY_SYMBOL_VISIBLE
      59              :     error_cat_type
      60              :     : std::error_category
      61              : {
      62              :     BOOST_CAPY_DECL const char* name(
      63              :         ) const noexcept override;
      64              :     BOOST_CAPY_DECL std::string message(
      65              :         int) const override;
      66              :     constexpr error_cat_type() noexcept = default;
      67              : };
      68              : 
      69              : BOOST_CAPY_DECL extern error_cat_type error_cat;
      70              : 
      71              : } // detail
      72              : 
      73              : //-----------------------------------------------
      74              : 
      75              : inline
      76              : std::error_code
      77         1381 : make_error_code(
      78              :     error ev) noexcept
      79              : {
      80         1381 :     return std::error_code{
      81              :         static_cast<std::underlying_type<
      82              :             error>::type>(ev),
      83         1381 :         detail::error_cat};
      84              : }
      85              : 
      86              : } // capy
      87              : } // boost
      88              : 
      89              : #endif
        

Generated by: LCOV version 2.3