14#include "libmesh/threads.h"
16#include "libmesh/print_trace.h"
17#include "libmesh/libmesh_common.h"
38template <
size_t n,
typename... T>
42 if constexpr (n <
sizeof...(T))
46 os << std::get<n>(tup);
47 print_tuple<n + 1>(os, tup);
50template <
typename... T>
52operator<<(std::ostream & os,
const std::tuple<T...> & tup)
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(""); \
106template <
typename... Args>
121 : runtime_error(message),
_node(node)
158mooseMsgFmt(
const std::string & msg,
const std::string & title,
const std::string & color);
166std::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);
187template <
typename T,
typename... Args>
195template <
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;
214template <
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;
230template <
typename S,
typename... Args>
234 std::ostringstream ss;
236 std::string msg =
mooseMsgFmt(ss.str(),
"*** Info ***", COLOR_CYAN);
239 oss << msg << std::flush;
243template <
typename S,
typename... Args>
250template <
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);
309template <
typename... Args>
313 std::ostringstream oss;
330template <
typename... Args>
334 std::ostringstream oss;
343template <
typename... Args>
352template <
typename... Args>
361template <
typename... Args>
366 Moose::out,
false,
true,
true, std::forward<Args>(args)...);
371template <
typename... Args>
376 Moose::out,
false,
true,
false, std::forward<Args>(args)...);
381template <
typename... Args>
390template <
typename... Args>
395 Moose::out,
true,
true,
false, std::forward<Args>(args)...);
399template <
typename... Args>
407template <
typename... Args>
void mooseInfoRepeated(Args &&... args)
Emit an informational message with the given stringified, concatenated args.
void mooseDeprecatedNoTrace(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
void print_tuple(std::ostream &os, const std::tuple< T... > &tup)
void mooseInfo(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.
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
std::ostream & operator<<(std::ostream &os, const std::tuple< T... > &tup)
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 mooseDeprecationExpired(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
void mooseUnused(Args &&... args)
Warning message used to notify the users of unused parts of their input files Really used internally ...
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Exception to be thrown whenever we have _throw_on_error set and a mooseError() is emitted.
MooseRuntimeError(const std::string &message, const hit::Node *const node)
const hit::Node * getNode() const
Get the associated hit node, if any.
const hit::Node *const _node
The associated hit node, if any.
This class provides an interface for common operations on field variables of both FE and FV types wit...
bool _deprecated_is_error
Variable to toggle only deprecated warnings as errors.
bool _throw_on_warning
Variable to turn on exceptions during mooseWarning(), should only be used in MOOSE unit tests.
bool _warnings_are_errors
Variable to toggle any warning into an error (includes deprecated code warnings)
std::string demangle(const char *name)
processor_id_type global_n_processors()
void print_trace(std::ostream &out_stream=std::cerr)
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.
void mooseWarningStream(S &oss, Args &&... args)
void mooseDeprecatedStream(S &oss, const bool expired, const bool print_title, const bool show_trace, Args &&... args)
libMesh::Threads::spin_mutex moose_stream_lock
std::string formatMooseDocumentedError(const std::string &repo_name, const unsigned int issue_num, const std::string &msg)
Formats a documented error.
std::string mooseMsgFmt(const std::string &msg, const std::string &title, const std::string &color)
Format a message for output with a title.
void mooseUnusedStream(S &oss, Args &&... 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::string incompatVarMsg(MooseVariableFieldBase &var1, MooseVariableFieldBase &var2)
Builds and returns a string of the form:
void mooseInfoStreamRepeated(S &oss, Args &&... args)
void mooseInfoStream(S &oss, Args &&... args)
void translateMetaPhysicLError(const MetaPhysicL::LogicError &)
emit a relatively clear error message when we catch a MetaPhysicL logic error