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;
128 ReportBase(
const char *file,
const char *function,
int line,
const char *condition_string,
const char *prefix) {
130 msg << prefix <<
" at " << file <<
":" << line <<
' ';
131 if (condition_string) {
132 msg <<
"Condition failed: " << condition_string <<
' ';
139 return *
static_cast<T *
>(
this);
145 return *
static_cast<T *
>(
this);
150 if (!msg.str().empty() && msg.str().back() !=
'\n') {
157template<
typename Exception>
161 ErrorReport(
const char *file,
const char *function,
int line,
const char *condition_string)
162 :
Base(file, function, line, condition_string, Exception::error_name) {
163 this->msg <<
"Error: ";
180 WarningReport(
const char *file,
const char *function,
int line,
const char *condition_string)
181 :
ReportBase(file, function, line, condition_string,
"Warning") {
182 this->msg <<
"Warning: ";
219#define _halide_internal_assertion(condition, type) \
221 (condition) ? (void)0 : ::Halide::Internal::Voidifier() & ::Halide::Internal::ErrorReport<type>(__FILE__, __FUNCTION__, __LINE__, #condition).ref()
223#define internal_error Halide::Internal::ErrorReport<Halide::InternalError>(__FILE__, __FUNCTION__, __LINE__, nullptr)
224#define user_error Halide::Internal::ErrorReport<Halide::CompileError>(__FILE__, __FUNCTION__, __LINE__, nullptr)
225#define user_warning Halide::Internal::WarningReport(__FILE__, __FUNCTION__, __LINE__, nullptr)
226#define halide_runtime_error Halide::Internal::ErrorReport<Halide::RuntimeError>(__FILE__, __FUNCTION__, __LINE__, nullptr)
228#define internal_assert(c) _halide_internal_assertion(c, Halide::InternalError)
229#define user_assert(c) _halide_internal_assertion(c, Halide::CompileError)
235#define _halide_internal_assert(c) _halide_internal_assertion(c, Halide::InternalError)
236#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 RuntimeError &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 &)
ErrorReport(const char *file, const char *function, int line, const char *condition_string)
~ErrorReport() noexcept(false)
When you're done using << on the object, and let it fall out of scope, this errors out,...
std::string finalize_message()
ReportBase(const char *file, const char *function, int line, const char *condition_string, const char *prefix)
HALIDE_ALWAYS_INLINE T & ref()
HALIDE_ALWAYS_INLINE T & operator<<(const S &x)
HALIDE_ALWAYS_INLINE void operator&(T &)
WarningReport(const char *file, const char *function, int line, const char *condition_string)
~WarningReport()
When you're done using << on the object, and let it fall out of scope, this prints the computed warni...
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)