14 #include "libmesh/threads.h" 16 #include "libmesh/print_trace.h" 17 #include "libmesh/libmesh_common.h" 22 #include <type_traits> 38 template <
size_t n,
typename... T>
42 if constexpr (n <
sizeof...(T))
46 os << std::get<n>(tup);
47 print_tuple<n + 1>(
os, tup);
50 template <
typename... T>
55 print_tuple<0>(
os, tup);
59 #define mooseDoOnce(do_this) \ 62 static bool did_this_already = false; \ 63 if (Moose::show_multiple || !did_this_already) \ 65 did_this_already = true; \ 70 #define mooseCheckMPIErr(err) \ 73 if (err != MPI_SUCCESS) \ 74 moose::internal::mooseErrorRaw(""); \ 77 #define mooseException(...) \ 80 throw MooseException(__VA_ARGS__); \ 84 #define mooseAssert(asserted, msg) ((void)0) 86 #define mooseAssert(asserted, msg) \ 91 std::ostringstream _assert_oss_; \ 92 _assert_oss_ << COLOR_RED << "\n\nAssertion `" #asserted "' failed\n" \ 93 << msg << "\nat " << __FILE__ << ", line " << __LINE__ << COLOR_DEFAULT \ 95 if (Moose::_throw_on_error) \ 96 throw std::runtime_error(_assert_oss_.str()); \ 99 Moose::err << _assert_oss_.str() << std::flush; \ 100 moose::internal::mooseErrorRaw(""); \ 106 template <
typename... Args>
107 [[noreturn]]
void mooseError(Args &&... args);
121 : runtime_error(message),
_node(node)
158 mooseMsgFmt(
const std::string & msg,
const std::string & title,
const std::string & color);
166 std::string
mooseMsgFmt(
const std::string & msg,
const std::string & color);
176 const std::string & prefix =
"",
177 const hit::Node * node =
nullptr,
178 const bool show_trace =
true);
187 template <
typename T,
typename... Args>
195 template <
typename S,
typename... Args>
202 std::ostringstream ss;
204 std::string msg =
mooseMsgFmt(ss.str(),
"*** Warning ***", COLOR_YELLOW);
206 throw std::runtime_error(msg);
210 oss << msg << std::flush;
214 template <
typename S,
typename... Args>
218 std::ostringstream ss;
220 std::string msg =
mooseMsgFmt(ss.str(),
"*** Warning ***", COLOR_YELLOW);
222 throw std::runtime_error(msg);
226 oss << msg << std::flush;
230 template <
typename S,
typename... Args>
234 std::ostringstream ss;
236 std::string msg =
mooseMsgFmt(ss.str(),
"*** Info ***", COLOR_CYAN);
239 oss << msg << std::flush;
243 template <
typename S,
typename... Args>
250 template <
typename S,
typename... Args>
253 S & oss,
const bool expired,
const bool print_title,
const bool show_trace, Args &&... args)
256 mooseError(
"\n\nDeprecated code:\n", std::forward<Args>(args)...);
258 std::ostringstream ss;
261 const auto color = expired ? COLOR_RED : COLOR_YELLOW;
262 std::string msg = print_title ?
mooseMsgFmt(ss.str(),
"*** Deprecation Warning ***", color)
274 oss << ss.str() << std::endl;
295 const unsigned int issue_num,
296 const std::string & msg);
309 template <
typename... Args>
313 std::ostringstream oss;
330 template <
typename... Args>
334 std::ostringstream oss;
343 template <
typename... Args>
352 template <
typename... Args>
361 template <
typename... Args>
366 Moose::out,
false,
true,
true, std::forward<Args>(args)...);
371 template <
typename... Args>
376 Moose::out,
false,
true,
false, std::forward<Args>(args)...);
381 template <
typename... Args>
390 template <
typename... Args>
395 Moose::out,
true,
true,
false, std::forward<Args>(args)...);
399 template <
typename... Args>
407 template <
typename... Args>
void mooseStreamAll(std::ostringstream &ss)
All of the following are not meant to be called directly - they are called by the normal macros (moos...
std::ostream & operator<<(std::ostream &os, const std::tuple< T... > &tup)
void mooseUnusedStream(S &oss, Args &&... args)
processor_id_type global_n_processors()
std::string incompatVarMsg(MooseVariableFieldBase &var1, MooseVariableFieldBase &var2)
Builds and returns a string of the form:
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
bool _warnings_are_errors
Variable to toggle any warning into an error (includes deprecated code warnings)
void translateMetaPhysicLError(const MetaPhysicL::LogicError &)
emit a relatively clear error message when we catch a MetaPhysicL logic error
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
void mooseDeprecationExpired(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
void mooseInfoRepeated(Args &&... args)
Emit an informational message with the given stringified, concatenated args.
void mooseDeprecationExpiredNoTrace(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
This class provides an interface for common operations on field variables of both FE and FV types wit...
std::basic_ostream< charT, traits > * os
void mooseInfoStream(S &oss, Args &&... args)
void mooseInfo(Args &&... args)
Emit an informational message with the given stringified, concatenated args.
const hit::Node * getNode() const
Get the associated hit node, if any.
void mooseUnused(Args &&... args)
Warning message used to notify the users of unused parts of their input files Really used internally ...
bool _deprecated_is_error
Variable to toggle only deprecated warnings as errors.
void mooseDeprecatedStream(S &oss, const bool expired, const bool print_title, const bool show_trace, Args &&... args)
void mooseWarningStream(S &oss, Args &&... args)
void mooseInfoStreamRepeated(S &oss, Args &&... args)
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
void mooseErrorRaw(std::string msg, const std::string &prefix="", const hit::Node *node=nullptr, const bool show_trace=true)
Main callback for emitting a moose error.
std::string demangle(const char *name)
void mooseDocumentedError(const std::string &repo_name, const unsigned int issue_num, Args &&... args)
Emit a documented error message with the given stringified, concatenated args and terminate the appli...
void print_trace(std::ostream &out_stream=std::cerr)
bool _throw_on_warning
Variable to turn on exceptions during mooseWarning(), should only be used in MOOSE unit tests...
MooseRuntimeError(const std::string &message, const hit::Node *const node)
void mooseDeprecatedNoTrace(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
const hit::Node *const _node
The associated hit node, if any.
Exception to be thrown whenever we have _throw_on_error set and a mooseError() is emitted...
libMesh::Threads::spin_mutex moose_stream_lock
void print_tuple(std::ostream &os, const std::tuple< T... > &tup)
std::string mooseMsgFmt(const std::string &msg, const std::string &title, const std::string &color)
Format a message for output with a title.
std::string formatMooseDocumentedError(const std::string &repo_name, const unsigned int issue_num, const std::string &msg)
Formats a documented error.