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

ArkScript-lang / Ark / 20074477466

09 Dec 2025 06:35PM UTC coverage: 90.587% (+0.02%) from 90.564%
20074477466

push

github

SuperFola
fix: use const string instead of constexpr string, otherwise compilers go bonkers about address of constexpr changing

2 of 2 new or added lines in 1 file covered. (100.0%)

16 existing lines in 2 files now uncovered.

8074 of 8913 relevant lines covered (90.59%)

360683.37 hits per line

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

97.62
/include/Ark/Error/Exceptions.hpp
1
/**
2
 * @file Exceptions.hpp
3
 * @author Lex Plateau (lexplt.dev@gmail.com), Max (madstk1@pm.me)
4
 * @brief ArkScript homemade exceptions
5
 * @date 2020-10-27
6
 *
7
 * @copyright Copyright (c) 2020-2025
8
 *
9
 */
10

11
#ifndef ARK_ERROR_EXCEPTIONS_HPP
12
#define ARK_ERROR_EXCEPTIONS_HPP
13

14
#include <string>
15
#include <utility>
16
#include <stdexcept>
17
#include <optional>
18

19
#include <Ark/Compiler/AST/utf8_char.hpp>
20
#include <Ark/Utils/Platform.hpp>
21
#include <Ark/Error/CodeErrorContext.hpp>
22

23
namespace Ark
24
{
25
    class VM;
26

27
    namespace internal
28
    {
29
        class Node;
30
    }
31

32
    class ARK_API Error : public std::runtime_error
730✔
33
    {
34
    public:
35
        explicit Error(const std::string& message) :
730✔
36
            std::runtime_error(message)
730✔
37
        {}
1,460✔
38

39
        [[nodiscard]] virtual std::string details(bool colorize [[maybe_unused]], VM& vm [[maybe_unused]]) const
10✔
40
        {
10✔
41
            return what();
10✔
UNCOV
42
        }
×
43
    };
44

45
    /**
46
     * @brief A type error triggered when types don't match
47
     *
48
     */
49
    class ARK_API TypeError final : public Error
4✔
50
    {
51
    public:
52
        explicit TypeError(const std::string& message) :
4✔
53
            Error(message)
4✔
54
        {}
8✔
55
    };
56

57
    /**
58
     * @brief An assertion error, only triggered from ArkScript code through (assert expr error-message)
59
     *
60
     */
61
    class ARK_API AssertionFailed final : public Error
2✔
62
    {
63
    public:
64
        explicit AssertionFailed(const std::string& message) :
2✔
65
            Error("AssertionFailed: " + message)
2✔
66
        {}
4✔
67
    };
68

69
    class ARK_API NestedError final : public Error
262✔
70
    {
71
    public:
72
        NestedError(const Error& e, const std::string& details, VM& vm) :
178✔
73
            Error("NestedError"),
178✔
74
            m_details(e.details(/* colorize= */ false, vm))
178✔
75
        {
356✔
76
            if (!m_details.empty() && m_details.back() != '\n')
178✔
77
                m_details += '\n';
10✔
78
            m_details += "\n" + details;
178✔
79
        }
178✔
80

81
        NestedError(const std::exception& e, const std::string& details) :
84✔
82
            Error("NestedError"),
84✔
83
            m_details(e.what())
84✔
84
        {
168✔
85
            if (!m_details.empty() && m_details.back() != '\n')
84✔
86
                m_details += '\n';
22✔
87
            m_details += "\n" + details;
84✔
88
        }
84✔
89

90
        [[nodiscard]] const char* what() const noexcept override
258✔
91
        {
258✔
92
            return m_details.c_str();
258✔
93
        }
94

95
    private:
96
        std::string m_details;
97
    };
98

99
    /**
100
     * @brief CodeError thrown by the compiler (parser, macro processor, optimizer, and compiler itself)
101
     *
102
     */
103
    struct ARK_API CodeError final : Error
286✔
104
    {
105
        const CodeErrorContext context;
106
        const std::optional<CodeErrorContext> additional_context;
107

108
        CodeError(const std::string& what, CodeErrorContext ctx, std::optional<CodeErrorContext> maybe_more_context = std::nullopt) :
286✔
109
            Error(what),
286✔
110
            context(std::move(ctx)),
286✔
111
            additional_context(std::move(maybe_more_context))
286✔
112
        {}
858✔
113
    };
114
}
115

116
#endif  // ARK_ERROR_EXCEPTIONS_HPP
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