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);
60 #if defined(LIBMESH_HAVE_MPI) 64 MPI_Abort(libMesh::GLOBAL_COMM_WORLD, 1); \ 75 #define mooseDoOnce(do_this) \ 78 static bool did_this_already = false; \ 79 if (Moose::show_multiple || !did_this_already) \ 81 did_this_already = true; \ 86 #define mooseCheckMPIErr(err) \ 89 if (err != MPI_SUCCESS) \ 91 if (libMesh::global_n_processors() == 1) \ 92 libMesh::print_trace(); \ 98 #define mooseException(...) \ 101 throw MooseException(__VA_ARGS__); \ 105 #define mooseAssert(asserted, msg) ((void)0) 107 #define mooseAssert(asserted, msg) \ 112 std::ostringstream _assert_oss_; \ 113 _assert_oss_ << COLOR_RED << "\n\nAssertion `" #asserted "' failed\n" \ 114 << msg << "\nat " << __FILE__ << ", line " << __LINE__ << COLOR_DEFAULT \ 116 if (Moose::_throw_on_error) \ 117 throw std::runtime_error(_assert_oss_.str()); \ 120 Moose::err << _assert_oss_.str() << std::flush; \ 121 if (libMesh::global_n_processors() == 1) \ 122 libMesh::print_trace(); \ 124 libMesh::write_traceout(); \ 132 template <
typename... Args>
133 [[noreturn]]
void mooseError(Args &&... args);
147 : runtime_error(message),
_node(node)
184 mooseMsgFmt(
const std::string & msg,
const std::string & title,
const std::string & color);
192 std::string
mooseMsgFmt(
const std::string & msg,
const std::string & color);
201 mooseErrorRaw(std::string msg,
const std::string & prefix =
"",
const hit::Node * node =
nullptr);
210 template <
typename T,
typename... Args>
218 template <
typename S,
typename... Args>
225 std::ostringstream ss;
227 std::string msg =
mooseMsgFmt(ss.str(),
"*** Warning ***", COLOR_YELLOW);
229 throw std::runtime_error(msg);
233 oss << msg << std::flush;
237 template <
typename S,
typename... Args>
241 std::ostringstream ss;
243 std::string msg =
mooseMsgFmt(ss.str(),
"*** Warning ***", COLOR_YELLOW);
245 throw std::runtime_error(msg);
249 oss << msg << std::flush;
253 template <
typename S,
typename... Args>
257 std::ostringstream ss;
259 std::string msg =
mooseMsgFmt(ss.str(),
"*** Info ***", COLOR_CYAN);
262 oss << msg << std::flush;
266 template <
typename S,
typename... Args>
273 template <
typename S,
typename... Args>
278 mooseError(
"\n\nDeprecated code:\n", std::forward<Args>(args)...);
280 std::ostringstream ss;
283 const auto color = expired ? COLOR_RED : COLOR_YELLOW;
284 std::string msg = print_title ?
mooseMsgFmt(ss.str(),
"*** Deprecation Warning ***", color)
296 oss << ss.str() << std::endl;
317 const unsigned int issue_num,
318 const std::string & msg);
331 template <
typename... Args>
335 std::ostringstream oss;
352 template <
typename... Args>
356 std::ostringstream oss;
365 template <
typename... Args>
374 template <
typename... Args>
382 template <
typename... Args>
390 template <
typename... Args>
398 template <
typename... Args>
406 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)
bool show_trace
Set to true (the default) to print the stack trace with error and warning messages - false to omit it...
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.
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 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.
std::string demangle(const char *name)
void mooseDeprecatedStream(S &oss, const bool expired, const bool print_title, Args &&... args)
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)
void mooseErrorRaw(std::string msg, const std::string &prefix="", const hit::Node *node=nullptr)
Main callback for emitting a moose error.
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)
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.