LCOV - code coverage report
Current view: top level - capy - error.hpp (source / functions) Coverage Total Hit
Test: coverage_remapped.info Lines: 100.0 % 3 3
Test Date: 2026-03-09 22:47:34 Functions: 100.0 % 1 1

           TLA  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 for capy I/O operations.
      20                 : 
      21                 :     These codes are produced by capy algorithms and I/O operations.
      22                 : 
      23                 :     @warning Callers must never compare received `error_code` values
      24                 :     directly against this enum. Always compare against the portable
      25                 :     @ref cond error conditions instead. These enum values are
      26                 :     implementation details subject to change.
      27                 : 
      28                 :     @see cond
      29                 : */
      30                 : enum class error
      31                 : {
      32                 :     /// End-of-stream reached. Compare with `cond::eof`.
      33                 :     eof = 1,
      34                 : 
      35                 :     /// Operation was cancelled. Compare with `cond::canceled`.
      36                 :     canceled,
      37                 : 
      38                 :     /// Internal test assertion failed.
      39                 :     test_failure,
      40                 : 
      41                 :     /// Peer closed connection without proper TLS shutdown.
      42                 :     /// Compare with `cond::stream_truncated`.
      43                 :     stream_truncated,
      44                 : 
      45                 :     /// Requested item was not found. Compare with `cond::not_found`.
      46                 :     not_found
      47                 : };
      48                 : 
      49                 : } // capy
      50                 : } // boost
      51                 : 
      52                 : namespace std {
      53                 : template<>
      54                 : struct is_error_code_enum<
      55                 :     ::boost::capy::error>
      56                 :     : std::true_type {};
      57                 : } // std
      58                 : 
      59                 : namespace boost {
      60                 : namespace capy {
      61                 : 
      62                 : namespace detail {
      63                 :  
      64                 : struct BOOST_CAPY_SYMBOL_VISIBLE
      65                 :     error_cat_type
      66                 :     : std::error_category
      67                 : {
      68                 :     BOOST_CAPY_DECL const char* name(
      69                 :         ) const noexcept override;
      70                 :     BOOST_CAPY_DECL std::string message(
      71                 :         int) const override;
      72                 :     constexpr error_cat_type() noexcept = default;
      73                 : };
      74                 : 
      75                 : BOOST_CAPY_DECL extern error_cat_type error_cat;
      76                 : 
      77                 : } // detail
      78                 : 
      79                 : /// Create an error_code from an error value.
      80                 : inline
      81                 : std::error_code
      82 HIT        2195 : make_error_code(
      83                 :     error ev) noexcept
      84                 : {
      85            2195 :     return std::error_code{
      86                 :         static_cast<std::underlying_type<
      87                 :             error>::type>(ev),
      88            2195 :         detail::error_cat};
      89                 : }
      90                 : 
      91                 : } // capy
      92                 : } // boost
      93                 : 
      94                 : #endif
        

Generated by: LCOV version 2.3