LCOV - code coverage report
Current view: top level - src/detail - make_err.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 66.7 % 6 4
Test Date: 2026-02-04 14:16:13 Functions: 100.0 % 1 1

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2025 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/corosio
       8              : //
       9              : 
      10              : #include "src/detail/make_err.hpp"
      11              : 
      12              : #include <boost/capy/error.hpp>
      13              : 
      14              : #if BOOST_COROSIO_POSIX
      15              : #include <errno.h>
      16              : #else
      17              : #ifndef WIN32_LEAN_AND_MEAN
      18              : #define WIN32_LEAN_AND_MEAN
      19              : #endif
      20              : #include <Windows.h>
      21              : #endif
      22              : 
      23              : namespace boost::corosio::detail {
      24              : 
      25              : #if BOOST_COROSIO_POSIX
      26              : 
      27              : std::error_code
      28           21 : make_err(int errn) noexcept
      29              : {
      30           21 :     if (errn == 0)
      31            0 :         return {};
      32              : 
      33           21 :     if (errn == ECANCELED)
      34            0 :         return capy::error::canceled;
      35              : 
      36           21 :     return std::error_code(errn, std::system_category());
      37              : }
      38              : 
      39              : #else
      40              : 
      41              : std::error_code
      42              : make_err(unsigned long dwError) noexcept
      43              : {
      44              :     if (dwError == 0)
      45              :         return {};
      46              : 
      47              :     if (dwError == ERROR_OPERATION_ABORTED ||
      48              :         dwError == ERROR_CANCELLED)
      49              :         return capy::error::canceled;
      50              : 
      51              :     if (dwError == ERROR_HANDLE_EOF)
      52              :         return capy::error::eof;
      53              : 
      54              :     return std::error_code(
      55              :         static_cast<int>(dwError),
      56              :         std::system_category());
      57              : }
      58              : 
      59              : #endif
      60              : 
      61              : } // namespace boost::corosio::detail
        

Generated by: LCOV version 2.3