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

ArkScript-lang / Ark / 17095454925

20 Aug 2025 10:15AM UTC coverage: 87.175% (-0.3%) from 87.426%
17095454925

Pull #571

github

web-flow
Merge 582ae8a8d into 120045f7e
Pull Request #571: Feat/better parser position tracking

594 of 697 new or added lines in 17 files covered. (85.22%)

5 existing lines in 2 files now uncovered.

7545 of 8655 relevant lines covered (87.18%)

129898.3 hits per line

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

88.1
/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
    namespace internal
26
    {
27
        class Node;
28
    }
29

30
    class ARK_API Error : public std::runtime_error
314✔
31
    {
32
    public:
33
        explicit Error(const std::string& message) :
314✔
34
            std::runtime_error(message)
314✔
35
        {}
628✔
36

37
        [[nodiscard]] virtual std::string details(bool colorize [[maybe_unused]]) const
1✔
38
        {
1✔
39
            return what();
1✔
NEW
40
        }
×
41
    };
42

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

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

67
    class ARK_API NestedError final : public Error
118✔
68
    {
69
    public:
70
        NestedError(const Error& e, const std::string& details) :
76✔
71
            Error("NestedError"),
76✔
72
            m_details(e.details(/* colorize= */ false))
76✔
73
        {
152✔
74
            if (!m_details.empty() && m_details.back() != '\n')
76✔
75
                m_details += '\n';
1✔
76
            m_details += "\n" + details;
76✔
77
        }
76✔
78

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

88
        [[nodiscard]] const char* what() const noexcept override
118✔
89
        {
118✔
90
            return m_details.c_str();
118✔
91
        }
92

93
    private:
94
        std::string m_details;
95
    };
96

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

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

114
#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