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

STEllAR-GROUP / hpx / #853

19 Dec 2022 01:01AM UTC coverage: 86.287% (+0.4%) from 85.912%
#853

push

StellarBot
Merge #6109

6109: Modernize serialization module r=hkaiser a=hkaiser

- flyby separate serialization of Boost types

working towards https://github.com/STEllAR-GROUP/hpx/issues/5497

Co-authored-by: Hartmut Kaiser <hartmut.kaiser@gmail.com>

53 of 53 new or added lines in 6 files covered. (100.0%)

173939 of 201582 relevant lines covered (86.29%)

1931657.12 hits per line

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

39.0
/libs/core/errors/src/exception_list.cpp
1
//  Copyright (c) 2007-2022 Hartmut Kaiser
2
//
3
//  SPDX-License-Identifier: BSL-1.0
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
#include <hpx/config.hpp>
8
#include <hpx/errors/exception.hpp>
9
#include <hpx/errors/exception_list.hpp>
10
#include <hpx/thread_support/unlock_guard.hpp>
11

12
#include <exception>
13
#include <mutex>
14
#include <set>
15
#include <string>
16
#include <system_error>
17
#include <utility>
18

19
namespace hpx {
20
    namespace detail {
21
        std::string indent_message(std::string const& msg_)
×
22
        {
23
            std::string result;
×
24
            std::string const& msg(msg_);
×
25
            std::string::size_type pos = msg.find_first_of('\n');
×
26
            std::string::size_type first_non_ws = msg.find_first_not_of(" \n");
×
27
            std::string::size_type pos1 = 0;
×
28

29
            while (std::string::npos != pos)
×
30
            {
31
                if (pos > first_non_ws)
×
32
                {    // skip leading newline
33
                    result += msg.substr(pos1, pos - pos1 + 1);
×
34
                    pos = msg.find_first_of('\n', pos1 = pos + 1);
×
35
                    if (std::string::npos != pos)
×
36
                    {
37
                        result += "  ";
×
38
                    }
×
39
                }
×
40
                else
41
                {
42
                    pos = msg.find_first_of('\n', pos1 = pos + 1);
×
43
                }
44
            }
45

46
            result += msg.substr(pos1);
×
47
            return result;
×
48
        }
×
49
    }    // namespace detail
50

51
    error_code throws;    // "throw on error" special error_code;
1,249✔
52
                          //
53
                          // Note that it doesn't matter if this isn't
54
                          // initialized before use since the only use is
55
                          // to take its address for comparison purposes.
56

57
    exception_list::exception_list()
90,805✔
58
      : hpx::exception(hpx::error::success)
90,805✔
59
      , mtx_()
90,805✔
60
    {
181,610✔
61
    }
90,805✔
62

63
    exception_list::exception_list(std::exception_ptr const& e)
3,862✔
64
      : hpx::exception(hpx::get_error(e), hpx::get_error_what(e))
1,931✔
65
      , mtx_()
1,931✔
66
    {
1,931✔
67
        add_no_lock(e);
1,931✔
68
    }
1,931✔
69

70
    exception_list::exception_list(exception_list_type&& l)
736✔
71
      : hpx::exception(
736✔
72
            !l.empty() ? hpx::get_error(l.front()) : hpx::error::success)
736✔
73
      , exceptions_(HPX_MOVE(l))
736✔
74
      , mtx_()
736✔
75
    {
1,472✔
76
    }
736✔
77

78
    exception_list::exception_list(exception_list const& l)
26✔
79
      : hpx::exception(static_cast<hpx::exception const&>(l))
26✔
80
      , exceptions_(l.exceptions_)
26✔
81
      , mtx_()
26✔
82
    {
52✔
83
    }
26✔
84

85
    exception_list::exception_list(exception_list&& l) noexcept
×
86
      : hpx::exception(HPX_MOVE(static_cast<hpx::exception&>(l)))
×
87
      , exceptions_(HPX_MOVE(l.exceptions_))
×
88
      , mtx_()
×
89
    {
×
90
    }
×
91

92
    exception_list& exception_list::operator=(exception_list const& l)
×
93
    {
94
        if (this != &l)
×
95
        {
96
            *static_cast<hpx::exception*>(this) =
×
97
                static_cast<hpx::exception const&>(l);
×
98
            exceptions_ = l.exceptions_;
×
99
        }
×
100
        return *this;
×
101
    }
102

103
    exception_list& exception_list::operator=(exception_list&& l) noexcept
×
104
    {
105
        if (this != &l)
×
106
        {
107
            static_cast<hpx::exception&>(*this) =
×
108
                HPX_MOVE(static_cast<hpx::exception&>(l));
×
109
            exceptions_ = HPX_MOVE(l.exceptions_);
×
110
        }
×
111
        return *this;
×
112
    }
113

114
    ///////////////////////////////////////////////////////////////////////////
115
    std::error_code exception_list::get_error() const
×
116
    {
117
        std::lock_guard<mutex_type> l(mtx_);
×
118
        if (exceptions_.empty())
×
119
            return hpx::error::no_success;
×
120
        return hpx::get_error(exceptions_.front());
×
121
    }
×
122

123
    std::string exception_list::get_message() const
×
124
    {
125
        std::lock_guard<mutex_type> l(mtx_);
×
126
        if (exceptions_.empty())
×
127
            return "";
×
128

129
        if (1 == exceptions_.size())
×
130
            return hpx::get_error_what(exceptions_.front());
×
131

132
        std::string result("\n");
×
133

134
        exception_list_type::const_iterator end = exceptions_.end();
×
135
        exception_list_type::const_iterator it = exceptions_.begin();
×
136
        for (/**/; it != end; ++it)
×
137
        {
138
            result += "  ";
×
139
            result += detail::indent_message(hpx::get_error_what(*it));
×
140
            if (result.find_last_of('\n') < result.size() - 1)
×
141
                result += "\n";
×
142
        }
×
143
        return result;
×
144
    }
×
145

146
    void exception_list::add(std::exception_ptr const& e)
38✔
147
    {
148
        std::unique_lock<mutex_type> l(mtx_);
38✔
149
        if (exceptions_.empty())
38✔
150
        {
151
            hpx::exception ex;
23✔
152
            {
153
                unlock_guard<std::unique_lock<mutex_type>> ul(l);
23✔
154
                ex = hpx::exception(hpx::get_error(e), hpx::get_error_what(e));
23✔
155
            }
23✔
156

157
            // set the error code for our base class
158
            static_cast<hpx::exception&>(*this) = ex;
23✔
159
        }
23✔
160
        exceptions_.push_back(e);
38✔
161
    }
38✔
162

163
    void exception_list::add_no_lock(std::exception_ptr const& e)
1,931✔
164
    {
165
        exceptions_.push_back(e);
1,931✔
166
    }
1,931✔
167
}    // namespace hpx
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

© 2026 Coveralls, Inc