28 explicit Error(
const char *msg);
29 explicit Error(
const std::string &msg);
38 virtual const
char *what() const noexcept;
50 static constexpr auto error_name =
"Runtime error";
59 static constexpr auto error_name =
"User error";
69 static constexpr auto error_name =
"Internal error";
85 virtual void warning(
const char *msg) = 0;
86 [[noreturn]]
virtual void error(
const char *msg) = 0;
129 return *
static_cast<T *
>(
this);
137 std::ostringstream msg{};
138 bool finalized{
false};
145 if (!msg.str().empty() && msg.str().back() !=
'\n') {
152 T &
init(
const char *file,
const char *function,
const int line,
const char *condition_string,
const char *prefix) {
154 msg << prefix <<
" at " << file <<
":" << line <<
' ';
155 if (condition_string) {
156 msg <<
"Condition failed: " << condition_string <<
' ';
159 return *
static_cast<T *
>(
this);
163template<
typename Exception>
165 ErrorReport &
init(
const char *file,
const char *function,
const int line,
const char *condition_string) {
169 [[noreturn]]
void issue() noexcept(false) {
175 WarningReport &
init(
const char *file,
const char *function,
const int line,
const char *condition_string) {
176 return ReportBase::init(file, function, line, condition_string,
"Warning") <<
"Warning: ";
199#define _halide_internal_diagnostic(condition, type, condition_string) \
201 if (!(condition)) for (type _err; _err; _err.issue()) _err.init(__FILE__, __FUNCTION__, __LINE__, condition_string)
204#define _halide_internal_error(type) \
205 _halide_internal_diagnostic(0, Halide::Internal::ErrorReport<type>, nullptr)
207#define _halide_internal_assertion(condition, type) \
208 _halide_internal_diagnostic(condition, Halide::Internal::ErrorReport<type>, #condition)
210#define user_error _halide_internal_error(Halide::CompileError)
211#define internal_error _halide_internal_error(Halide::InternalError)
212#define halide_runtime_error _halide_internal_error(Halide::RuntimeError)
214#define user_warning _halide_internal_diagnostic(0, Halide::Internal::WarningReport, nullptr)
216#define internal_assert(c) _halide_internal_assertion(c, Halide::InternalError)
217#define user_assert(c) _halide_internal_assertion(c, Halide::CompileError)
223#define _halide_internal_assert(c) _halide_internal_assertion(c, Halide::InternalError)
224#define _halide_user_assert(c) _halide_internal_assertion(c, Halide::CompileError)
Defines functions for debug logging during code generation.
This file declares the routines used by Halide internally in its runtime.
#define HALIDE_EXPORT_SYMBOL
#define HALIDE_ALWAYS_INLINE
CompileTimeErrorReporter is used at compile time (not runtime) when an error or warning is generated ...
virtual void warning(const char *msg)=0
virtual void error(const char *msg)=0
virtual ~CompileTimeErrorReporter()=default
void throw_error(const InternalError &e)
If a custom error reporter is configured, notifies the reporter by calling its error() function with ...
void issue_warning(const char *warning)
If a custom error reporter is configured, notifies the reporter by calling its warning() function.
HALIDE_EXPORT_SYMBOL void unhandled_exception_handler()
bool debug_is_active_impl(int verbosity, const char *file, const char *function, int line)
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
bool exceptions_enabled()
Query whether Halide was compiled with exceptions.
void set_custom_compile_time_error_reporter(CompileTimeErrorReporter *error_reporter)
The default error reporter logs to stderr, then throws an exception (if HALIDE_WITH_EXCEPTIONS) or ca...
An error that occurs while compiling a Halide pipeline that Halide attributes to a user error.
CompileError(const char *msg)
CompileError(const std::string &msg)
A base class for Halide errors.
Error(const std::string &msg)
Error & operator=(const Error &)
void issue() noexcept(false)
ErrorReport & init(const char *file, const char *function, const int line, const char *condition_string)
std::string finalize_message()
T & init(const char *file, const char *function, const int line, const char *condition_string, const char *prefix)
HALIDE_ALWAYS_INLINE T & operator<<(const S &x)
WarningReport & init(const char *file, const char *function, const int line, const char *condition_string)
An error that occurs while compiling a Halide pipeline that Halide attributes to an internal compiler...
InternalError(const std::string &msg)
InternalError(const char *msg)
An error that occurs while running a JIT-compiled Halide pipeline.
RuntimeError(const char *msg)
RuntimeError(const std::string &msg)