• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

STEllAR-GROUP / hpx / #882

31 Aug 2023 07:44PM UTC coverage: 41.798% (-44.7%) from 86.546%
#882

push

19442 of 46514 relevant lines covered (41.8%)

126375.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/libs/core/errors/src/throw_exception.cpp
1
//  Copyright (c) 2007-2024 Hartmut Kaiser
2
//  Copyright (c)      2011 Bryce Lelbach
3
//
4
//  SPDX-License-Identifier: BSL-1.0
5
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
6
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7

8
#include <hpx/config.hpp>
9
#include <hpx/errors/error.hpp>
10
#include <hpx/errors/exception.hpp>
11
#include <hpx/modules/filesystem.hpp>
12

13
#include <exception>
14
#include <string>
15
#include <system_error>
16

17
namespace hpx::detail {
18

19
    [[noreturn]] void throw_exception(error errcode, std::string const& msg,
×
20
        std::string const& func, std::string const& file, long line)
21
    {
22
        filesystem::path const p(file);
×
23
        hpx::detail::throw_exception(
×
24
            hpx::exception(errcode, msg, hpx::throwmode::plain), func,
×
25
            p.string(), line);
×
26
    }
×
27

28
    [[noreturn]] void rethrow_exception(
×
29
        exception const& e, std::string const& func)
30
    {
31
        hpx::detail::throw_exception(
×
32
            hpx::exception(e.get_error(), e.what(), hpx::throwmode::rethrow),
×
33
            func, hpx::get_error_file_name(e), hpx::get_error_line_number(e));
34
    }
35

36
    std::exception_ptr get_exception(error errcode, std::string const& msg,
5✔
37
        throwmode mode, std::string const& /* func */, std::string const& file,
38
        long line, std::string const& auxinfo)
39
    {
40
        filesystem::path const p(file);
5✔
41
        return hpx::detail::get_exception(hpx::exception(errcode, msg, mode),
10✔
42
            p.string(), file, line, auxinfo);
10✔
43
    }
5✔
44

45
    std::exception_ptr get_exception(std::error_code const& ec,
×
46
        std::string const& /* msg */, throwmode /* mode */,
47
        std::string const& func, std::string const& file, long line,
48
        std::string const& auxinfo)
49
    {
50
        return hpx::detail::get_exception(
51
            hpx::exception(ec), func, file, line, auxinfo);
×
52
    }
53

54
    void throws_if(hpx::error_code& ec, error errcode, std::string const& msg,
1,504✔
55
        std::string const& func, std::string const& file, long line)
56
    {
57
        if (&ec == &hpx::throws)
1,504✔
58
        {
59
            hpx::detail::throw_exception(errcode, msg, func, file, line);
×
60
        }
61
        else
62
        {
63
            ec = make_error_code(static_cast<hpx::error>(errcode), msg,
1,504✔
64
                func.c_str(), file.c_str(), line,
65
                (ec.category() == hpx::get_lightweight_hpx_category()) ?
1,504✔
66
                    hpx::throwmode::lightweight :
67
                    hpx::throwmode::plain);
1,504✔
68
        }
69
    }
1,504✔
70

71
    void throws_bad_alloc_if(
×
72
        hpx::error_code& ec, char const* func, char const* file, long line)
73
    {
74
        if (&ec == &hpx::throws)
×
75
        {
76
            throw hpx::bad_alloc_exception();
×
77
        }
78
        else
79
        {
80
            ec = make_error_code(hpx::error::out_of_memory, "out of memory",
×
81
                func, file, line,
×
82
                (ec.category() == hpx::get_lightweight_hpx_category()) ?
83
                    hpx::throwmode::lightweight :
×
84
                    hpx::throwmode::plain);
85
        }
×
86
    }
87

×
88
    void rethrows_if(
89
        hpx::error_code& ec, exception const& e, std::string const& func)
×
90
    {
91
        if (&ec == &hpx::throws)
×
92
        {
93
            hpx::detail::rethrow_exception(e, func);
94
        }
95
        else
96
        {
97
            ec = make_error_code(e.get_error(), e.what(), func.c_str(),
98
                hpx::get_error_file_name(e).c_str(),
99
                hpx::get_error_line_number(e),
100
                (ec.category() == hpx::get_lightweight_hpx_category()) ?
101
                    hpx::throwmode::lightweight_rethrow :
102
                    hpx::throwmode::rethrow);
103
        }
104
    }
105

106
    [[noreturn]] void throw_thread_interrupted_exception()
107
    {
108
        throw hpx::thread_interrupted();
109
    }
110
}    // namespace hpx::detail
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc