@@ -48,7 +48,8 @@ struct HALIDE_EXPORT_SYMBOL Error {
4848
4949/* * An error that occurs while running a JIT-compiled Halide pipeline. */
5050struct HALIDE_EXPORT_SYMBOL RuntimeError final : Error {
51- static constexpr auto error_name = " Runtime error" ;
51+ static constexpr auto verbose_name = " Runtime error" ;
52+ static constexpr int verbose_debug_level = 1 ;
5253
5354 explicit RuntimeError (const char *msg);
5455 explicit RuntimeError (const std::string &msg);
@@ -57,7 +58,8 @@ struct HALIDE_EXPORT_SYMBOL RuntimeError final : Error {
5758/* * An error that occurs while compiling a Halide pipeline that Halide
5859 * attributes to a user error. */
5960struct HALIDE_EXPORT_SYMBOL CompileError final : Error {
60- static constexpr auto error_name = " User error" ;
61+ static constexpr auto verbose_name = " User error" ;
62+ static constexpr int verbose_debug_level = 1 ;
6163
6264 explicit CompileError (const char *msg);
6365 explicit CompileError (const std::string &msg);
@@ -67,7 +69,8 @@ struct HALIDE_EXPORT_SYMBOL CompileError final : Error {
6769 * attributes to an internal compiler bug, or to an invalid use of
6870 * Halide's internals. */
6971struct HALIDE_EXPORT_SYMBOL InternalError final : Error {
70- static constexpr auto error_name = " Internal error" ;
72+ static constexpr auto verbose_name = " Internal error" ;
73+ static constexpr int verbose_debug_level = 0 ; // Always print location/condition info
7174
7275 explicit InternalError (const char *msg);
7376 explicit InternalError (const std::string &msg);
@@ -154,11 +157,11 @@ class ReportBase {
154157 return contents->msg .str ();
155158 }
156159
157- T &init (const char *file, const char *function, const int line, const char *condition_string, const char *prefix ) {
158- if (debug_is_active_impl (1 , file, function, line)) {
159- contents->msg << prefix << " at " << file << " :" << line << ' ' ;
160+ T &init (const char *file, const char *function, const int line, const char *condition_string) {
161+ if (debug_is_active_impl (T::verbose_debug_level , file, function, line)) {
162+ contents->msg << T::verbose_name << " at " << file << " :" << line << ' \n ' ;
160163 if (condition_string) {
161- contents->msg << " Condition failed: " << condition_string << ' ' ;
164+ contents->msg << " Condition failed: " << condition_string << ' \n ' ;
162165 }
163166 }
164167 return *static_cast <T *>(this );
@@ -167,8 +170,11 @@ class ReportBase {
167170
168171template <typename Exception>
169172struct ErrorReport final : ReportBase<ErrorReport<Exception>> {
173+ static constexpr auto verbose_name = Exception::verbose_name;
174+ static constexpr int verbose_debug_level = Exception::verbose_debug_level;
175+
170176 ErrorReport &init (const char *file, const char *function, const int line, const char *condition_string) {
171- return ReportBase<ErrorReport>::init (file, function, line, condition_string, Exception::error_name ) << " Error: " ;
177+ return ReportBase<ErrorReport>::init (file, function, line, condition_string) << " Error: " ;
172178 }
173179
174180 [[noreturn]] void issue () noexcept (false ) {
@@ -177,8 +183,11 @@ struct ErrorReport final : ReportBase<ErrorReport<Exception>> {
177183};
178184
179185struct WarningReport final : ReportBase<WarningReport> {
186+ static constexpr auto verbose_name = " Warning" ;
187+ static constexpr int verbose_debug_level = 1 ;
188+
180189 WarningReport &init (const char *file, const char *function, const int line, const char *condition_string) {
181- return ReportBase::init (file, function, line, condition_string, " Warning " ) << " Warning: " ;
190+ return ReportBase::init (file, function, line, condition_string) << " Warning: " ;
182191 }
183192
184193 void issue () {
0 commit comments