GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 77.8% 7 / 0 / 9
Functions: 71.4% 5 / 0 / 7
Branches: 66.7% 2 / 0 / 3

src/utilities/core/Exception.hpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #ifndef UTILITIES_CORE_EXCEPTION_HPP
7 #define UTILITIES_CORE_EXCEPTION_HPP
8
9 #include <string>
10 #include <exception>
11 #include "../UtilitiesAPI.hpp"
12
13 namespace openstudio {
14
15 /** Base class for exceptions. */
16 class UTILITIES_API Exception : public std::exception
17 {
18 public:
19 /// Constructor takes a message
20
1/1
✓ Branch 2 taken 319 times.
319 Exception(const std::string& msg) : m_msg(msg) {}
21
22 /// Needed for rb_raise support in swig
23
1/1
✓ Branch 2 taken 14 times.
42 Exception(const char* msg) : m_msg(msg) {}
24
25 ✗ Exception(const Exception&) = default;
26 Exception& operator=(const Exception&) = default;
27 ✗ Exception(Exception&&) = default;
28 Exception& operator=(Exception&&) = default;
29 307 virtual ~Exception() noexcept override = default;
30
31 /// return the message
32 32 virtual const std::string& message() const {
33 32 return m_msg;
34 }
35
36 /// return the message
37 43 virtual const char* what() const noexcept override {
38 43 return m_msg.c_str();
39 }
40
41 private:
42 std::string m_msg;
43 };
44
45 } // namespace openstudio
46
47 #endif // UTILITIES_CORE_EXCEPTION_HPP
48