11#ifndef ARK_ERROR_EXCEPTIONS_HPP
12#define ARK_ERROR_EXCEPTIONS_HPP
33 explicit Error(
const std::string& message) :
34 std::runtime_error(message)
37 [[nodiscard]]
virtual std::string
details(
bool colorize [[maybe_unused]])
const
63 Error(
"AssertionFailed: " + message)
72 m_details(e.details( false))
74 if (!m_details.empty() && m_details.back() !=
'\n')
76 m_details +=
"\n" + details;
79 NestedError(
const std::exception& e,
const std::string& details) :
83 if (!m_details.empty() && m_details.back() !=
'\n')
85 m_details +=
"\n" + details;
88 [[nodiscard]]
const char*
what() const noexcept
override
90 return m_details.c_str();
108 context(
std::move(ctx)),
109 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) const
Error(const std::string &message)
NestedError(const Error &e, const std::string &details)
NestedError(const std::exception &e, const std::string &details)
const char * what() const noexcept override
A type error triggered when types don't match.
TypeError(const std::string &message)
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)