11#ifndef ARK_ERROR_EXCEPTIONS_HPP
12#define ARK_ERROR_EXCEPTIONS_HPP
35 explicit Error(
const std::string& message) :
36 std::runtime_error(message)
39 [[nodiscard]]
virtual std::string
details(
bool colorize [[maybe_unused]],
VM& vm [[maybe_unused]])
const
65 Error(
"AssertionFailed: " + message)
74 m_details(e.details( false, vm))
76 if (!m_details.empty() && m_details.back() !=
'\n')
78 m_details +=
"\n" + details;
81 NestedError(
const std::exception& e,
const std::string& details) :
85 if (!m_details.empty() && m_details.back() !=
'\n')
87 m_details +=
"\n" + details;
90 [[nodiscard]]
const char*
what() const noexcept
override
92 return m_details.c_str();
110 context(
std::move(ctx)),
111 additional_context(
std::move(maybe_more_context))
Defines a code error context.
An assertion error, only triggered from ArkScript code through (assert expr error-message)
AssertionFailed(const std::string &message)
virtual std::string details(bool colorize, VM &vm) const
Error(const std::string &message)
NestedError(const std::exception &e, const std::string &details)
const char * what() const noexcept override
NestedError(const Error &e, const std::string &details, VM &vm)
A type error triggered when types don't match.
TypeError(const std::string &message)
The ArkScript virtual machine, executing ArkScript bytecode.
CodeError thrown by the compiler (parser, macro processor, optimizer, and compiler itself)
const std::optional< CodeErrorContext > additional_context
const CodeErrorContext context
CodeError(const std::string &what, CodeErrorContext ctx, std::optional< CodeErrorContext > maybe_more_context=std::nullopt)