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

Functions

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)
 
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 mooseInfoStream (S &oss, Args &&...args)
 
template<typename S , typename... Args>
void mooseDeprecatedStream (S &oss, Args &&...args)
 

Variables

static Threads::spin_mutex moose_err_lock
 

Function Documentation

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

Definition at line 157 of file MooseError.h.

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

158 {
160  mooseError("\n\nDeprecated code:\n", std::forward<Args>(args)...);
161 
162  mooseDoOnce(std::ostringstream ss; mooseStreamAll(ss, args...);
163  std::string msg = mooseMsgFmt(
164  ss.str(),
165  "*** Warning, This code is deprecated and will be removed in future versions!",
166  COLOR_YELLOW);
167  oss << msg;
168  ss.str("");
169  if (libMesh::global_n_processors() == 1) print_trace(ss);
170  else libMesh::write_traceout();
171  oss << ss.str() << std::endl;);
172 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
bool _deprecated_is_error
Variable to toggle only deprecated warnings as errors.
Definition: Moose.C:1284
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&...args)
Definition: MooseError.h:121
std::string mooseMsgFmt(const std::string &msg, const std::string &title, const std::string &color)
Definition: MooseError.C:24
void moose::internal::mooseErrorRaw ( std::string  msg,
const std::string  prefix = "" 
)

Definition at line 34 of file MooseError.C.

Referenced by callMooseErrorRaw(), and mooseError().

35 {
36  msg = mooseMsgFmt(msg, "*** ERROR ***", COLOR_RED);
37 
39  {
40  if (!prefix.empty())
41  MooseUtils::indentMessage(prefix, msg);
42  throw std::runtime_error(msg);
43  }
44 
45  std::ostringstream oss;
46  oss << msg << "\n";
47 
48  // this independent flush of the partial error message (i.e. without the
49  // trace) is here because trace retrieval can be slow in some
50  // circumstances, and we want to get the error message out ASAP.
51  msg = oss.str();
52  if (!prefix.empty())
53  MooseUtils::indentMessage(prefix, msg);
54  {
55  Threads::spin_mutex::scoped_lock lock(moose_err_lock);
56  Moose::err << msg << std::flush;
57  }
58 
59  oss.str("");
60  if (libMesh::global_n_processors() == 1)
61  print_trace(oss);
62 
63  msg = oss.str();
64  if (!prefix.empty())
65  MooseUtils::indentMessage(prefix, msg);
66 
67  Threads::spin_mutex::scoped_lock lock(moose_err_lock);
68 
69  Moose::err << msg << std::flush;
70 
71  if (libMesh::global_n_processors() > 1)
72  libMesh::write_traceout();
73 
74  MOOSE_ABORT;
75 }
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:438
static Threads::spin_mutex moose_err_lock
Definition: MooseError.C:31
bool _throw_on_error
Variable to turn on exceptions during mooseError() and mooseWarning(), should only be used with MOOSE...
Definition: Moose.C:1286
std::string mooseMsgFmt(const std::string &msg, const std::string &title, const std::string &color)
Definition: MooseError.C:24
template<typename S , typename... Args>
void moose::internal::mooseInfoStream ( S &  oss,
Args &&...  args 
)

Definition at line 145 of file MooseError.h.

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

146 {
147  mooseDoOnce({
148  std::ostringstream ss;
149  mooseStreamAll(ss, args...);
150  std::string msg = mooseMsgFmt(ss.str(), "*** Info ***", COLOR_CYAN);
151  oss << msg << std::flush;
152  });
153 }
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&...args)
Definition: MooseError.h:121
std::string mooseMsgFmt(const std::string &msg, const std::string &title, const std::string &color)
Definition: MooseError.C:24
std::string moose::internal::mooseMsgFmt ( const std::string &  msg,
const std::string &  title,
const std::string &  color 
)

Definition at line 24 of file MooseError.C.

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

25 {
26  std::ostringstream oss;
27  oss << "\n\n" << color << "\n\n" << title << "\n" << msg << COLOR_DEFAULT << "\n\n";
28  return oss.str();
29 }
void moose::internal::mooseStreamAll ( std::ostringstream &  ss)
template<typename T , typename... Args>
void moose::internal::mooseStreamAll ( std::ostringstream &  ss,
T &&  val,
Args &&...  args 
)

Definition at line 121 of file MooseError.h.

122 {
123  ss << val;
124  mooseStreamAll(ss, std::forward<Args>(args)...);
125 }
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&...args)
Definition: MooseError.h:121
template<typename S , typename... Args>
void moose::internal::mooseWarningStream ( S &  oss,
Args &&...  args 
)

Definition at line 129 of file MooseError.h.

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

130 {
132  mooseError(std::forward<Args>(args)...);
133 
134  std::ostringstream ss;
135  mooseStreamAll(ss, args...);
136  std::string msg = mooseMsgFmt(ss.str(), "*** Warning ***", COLOR_YELLOW);
138  throw std::runtime_error(msg);
139 
140  oss << msg << std::flush;
141 }
bool _warnings_are_errors
Variable to toggle any warning into an error (includes deprecated code warnings)
Definition: Moose.C:1282
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
bool _throw_on_error
Variable to turn on exceptions during mooseError() and mooseWarning(), should only be used with MOOSE...
Definition: Moose.C:1286
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&...args)
Definition: MooseError.h:121
std::string mooseMsgFmt(const std::string &msg, const std::string &title, const std::string &color)
Definition: MooseError.C:24

Variable Documentation

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

Definition at line 31 of file MooseError.C.