www.mooseframework.org
Functions | Variables
moose::internal Namespace Reference

Functions

std::string incompatVarMsg (MooseVariableFEBase &var1, MooseVariableFEBase &var2)
 Builds and returns a string of the form: More...
 
std::string mooseMsgFmt (const std::string &msg, const std::string &title, const std::string &color)
 
void mooseErrorRaw (std::string msg, const std::string prefix="")
 
void mooseStreamAll (std::ostringstream &ss)
 All of the following are not meant to be called directly - they are called by the normal macros (mooseError(), etc.) down below. More...
 
template<typename T , typename... Args>
void mooseStreamAll (std::ostringstream &ss, T &&val, Args &&... args)
 
template<typename S , typename... Args>
void mooseWarningStream (S &oss, Args &&... args)
 
template<typename S , typename... Args>
void mooseUnusedStream (S &oss, Args &&... args)
 
template<typename S , typename... Args>
void mooseInfoStream (S &oss, Args &&... args)
 
template<typename S , typename... Args>
void mooseDeprecatedStream (S &oss, bool expired, Args &&... args)
 

Variables

static Threads::spin_mutex moose_err_lock
 

Function Documentation

◆ incompatVarMsg()

std::string moose::internal::incompatVarMsg ( MooseVariableFEBase var1,
MooseVariableFEBase var2 
)

Builds and returns a string of the form:

[var1-elemtype],ORDER[var1-order] != [var2-elemtype],ORDER[var2-order]

This is a convenience function to be used when error messages (especially with paramError) need to report that variable types are incompatible (e.g. with residual save-in).

Definition at line 22 of file MooseError.C.

Referenced by ADIntegratedBCTempl< T, compute_stage >::ADIntegratedBCTempl(), ADKernelTempl< T, compute_stage >::ADKernelTempl(), DGKernelBase::DGKernelBase(), IntegratedBC::IntegratedBC(), Kernel::Kernel(), NodalBC::NodalBC(), NodalKernel::NodalKernel(), and MultiAppCopyTransfer::transfer().

23 {
24  std::stringstream ss;
25  ss << libMesh::Utility::enum_to_string<FEFamily>(var1.feType().family) << ",ORDER"
26  << var1.feType().order
27  << " != " << libMesh::Utility::enum_to_string<FEFamily>(var2.feType().family) << ",ORDER"
28  << var2.feType().order;
29  return ss.str();
30 }
const FEType & feType() const
Get the type of finite element object.

◆ mooseDeprecatedStream()

template<typename S , typename... Args>
void moose::internal::mooseDeprecatedStream ( S &  oss,
bool  expired,
Args &&...  args 
)

Definition at line 179 of file MooseError.h.

Referenced by MooseObject::mooseDeprecated(), mooseDeprecated(), and mooseDeprecationExpired().

180 {
182  mooseError("\n\nDeprecated code:\n", std::forward<Args>(args)...);
183 
184  mooseDoOnce(std::ostringstream ss; mooseStreamAll(ss, args...);
185  std::string msg = mooseMsgFmt(
186  ss.str(),
187  "*** Warning, This code is deprecated and will be removed in future versions!\n",
188  expired ? COLOR_RED : COLOR_YELLOW);
189  oss << msg;
190  ss.str("");
191  if (libMesh::global_n_processors() == 1) print_trace(ss);
192  else libMesh::write_traceout();
193  oss << ss.str() << std::endl;);
194 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
bool _deprecated_is_error
Variable to toggle only deprecated warnings as errors.
Definition: Moose.C:572
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&... args)
Definition: MooseError.h:130
std::string mooseMsgFmt(const std::string &msg, const std::string &title, const std::string &color)
Definition: MooseError.C:33

◆ mooseErrorRaw()

void moose::internal::mooseErrorRaw ( std::string  msg,
const std::string  prefix = "" 
)

Definition at line 43 of file MooseError.C.

Referenced by callMooseErrorRaw(), and mooseError().

44 {
45  msg = mooseMsgFmt(msg, "*** ERROR ***", COLOR_RED);
46 
48  {
49  if (!prefix.empty())
50  MooseUtils::indentMessage(prefix, msg);
51  throw std::runtime_error(msg);
52  }
53 
54  std::ostringstream oss;
55  oss << msg << "\n";
56 
57  // this independent flush of the partial error message (i.e. without the
58  // trace) is here because trace retrieval can be slow in some
59  // circumstances, and we want to get the error message out ASAP.
60  msg = oss.str();
61  if (!prefix.empty())
62  MooseUtils::indentMessage(prefix, msg);
63  {
64  Threads::spin_mutex::scoped_lock lock(moose_err_lock);
65  Moose::err << msg << std::flush;
66  }
67 
68  oss.str("");
69  if (libMesh::global_n_processors() == 1)
70  print_trace(oss);
71 
72  msg = oss.str();
73  if (!prefix.empty())
74  MooseUtils::indentMessage(prefix, msg);
75 
76  Threads::spin_mutex::scoped_lock lock(moose_err_lock);
77 
78  Moose::err << msg << std::flush;
79 
80  if (libMesh::global_n_processors() > 1)
81  libMesh::write_traceout();
82 
83  MOOSE_ABORT;
84 }
void indentMessage(const std::string &prefix, std::string &message, const char *color=COLOR_CYAN)
Indents the supplied message given the prefix and color.
Definition: MooseUtils.C:431
static Threads::spin_mutex moose_err_lock
Definition: MooseError.C:40
bool _throw_on_error
Variable to turn on exceptions during mooseError() and mooseWarning(), should only be used with MOOSE...
Definition: Moose.C:574
std::string mooseMsgFmt(const std::string &msg, const std::string &title, const std::string &color)
Definition: MooseError.C:33

◆ mooseInfoStream()

template<typename S , typename... Args>
void moose::internal::mooseInfoStream ( S &  oss,
Args &&...  args 
)

Definition at line 167 of file MooseError.h.

Referenced by MooseObject::mooseInfo(), and mooseInfo().

168 {
169  mooseDoOnce({
170  std::ostringstream ss;
171  mooseStreamAll(ss, args...);
172  std::string msg = mooseMsgFmt(ss.str(), "*** Info ***", COLOR_CYAN);
173  oss << msg << std::flush;
174  });
175 }
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&... args)
Definition: MooseError.h:130
std::string mooseMsgFmt(const std::string &msg, const std::string &title, const std::string &color)
Definition: MooseError.C:33

◆ mooseMsgFmt()

std::string moose::internal::mooseMsgFmt ( const std::string &  msg,
const std::string &  title,
const std::string &  color 
)

Definition at line 33 of file MooseError.C.

Referenced by mooseDeprecatedStream(), mooseErrorRaw(), mooseInfoStream(), mooseUnusedStream(), and mooseWarningStream().

34 {
35  std::ostringstream oss;
36  oss << "\n\n" << color << "\n\n" << title << "\n" << msg << COLOR_DEFAULT << "\n\n";
37  return oss.str();
38 }

◆ mooseStreamAll() [1/2]

void moose::internal::mooseStreamAll ( std::ostringstream &  ss)

All of the following are not meant to be called directly - they are called by the normal macros (mooseError(), etc.) down below.

Definition at line 87 of file MooseError.C.

Referenced by mooseDeprecatedStream(), mooseError(), MooseObject::mooseError(), mooseInfoStream(), mooseStreamAll(), mooseUnusedStream(), and mooseWarningStream().

88 {
89 }

◆ mooseStreamAll() [2/2]

template<typename T , typename... Args>
void moose::internal::mooseStreamAll ( std::ostringstream &  ss,
T &&  val,
Args &&...  args 
)

Definition at line 130 of file MooseError.h.

131 {
132  ss << val;
133  mooseStreamAll(ss, std::forward<Args>(args)...);
134 }
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&... args)
Definition: MooseError.h:130

◆ mooseUnusedStream()

template<typename S , typename... Args>
void moose::internal::mooseUnusedStream ( S &  oss,
Args &&...  args 
)

Definition at line 154 of file MooseError.h.

Referenced by mooseUnused().

155 {
156  std::ostringstream ss;
157  mooseStreamAll(ss, args...);
158  std::string msg = mooseMsgFmt(ss.str(), "*** Warning ***", COLOR_YELLOW);
160  throw std::runtime_error(msg);
161 
162  oss << msg << std::flush;
163 }
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&... args)
Definition: MooseError.h:130
bool _throw_on_error
Variable to turn on exceptions during mooseError() and mooseWarning(), should only be used with MOOSE...
Definition: Moose.C:574
std::string mooseMsgFmt(const std::string &msg, const std::string &title, const std::string &color)
Definition: MooseError.C:33

◆ mooseWarningStream()

template<typename S , typename... Args>
void moose::internal::mooseWarningStream ( S &  oss,
Args &&...  args 
)

Definition at line 138 of file MooseError.h.

Referenced by MooseObject::mooseWarning(), and mooseWarning().

139 {
141  mooseError(std::forward<Args>(args)...);
142 
143  std::ostringstream ss;
144  mooseStreamAll(ss, args...);
145  std::string msg = mooseMsgFmt(ss.str(), "*** Warning ***", COLOR_YELLOW);
147  throw std::runtime_error(msg);
148 
149  oss << msg << std::flush;
150 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
bool _warnings_are_errors
Variable to toggle any warning into an error (includes deprecated code warnings)
Definition: Moose.C:570
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&... args)
Definition: MooseError.h:130
bool _throw_on_error
Variable to turn on exceptions during mooseError() and mooseWarning(), should only be used with MOOSE...
Definition: Moose.C:574
std::string mooseMsgFmt(const std::string &msg, const std::string &title, const std::string &color)
Definition: MooseError.C:33

Variable Documentation

◆ moose_err_lock

Threads::spin_mutex moose::internal::moose_err_lock
static

Definition at line 40 of file MooseError.C.

Referenced by mooseErrorRaw().