Go to the documentation of this file.
52 <<
" This " << what <<
" is considered to be VERY old!\n"
65 <<
" This " << what <<
" is deemed to be " << months
87 functionName_(
"unknown"),
88 sourceFileName_(
"unknown"),
89 sourceFileLineNumber_(0),
99 functionName_(errDict.get<
string>(
"functionName")),
100 sourceFileName_(errDict.get<
string>(
"sourceFileName")),
101 sourceFileLineNumber_(errDict.get<label>(
"sourceFileLineNumber")),
111 functionName_(err.functionName_),
112 sourceFileName_(err.sourceFileName_),
113 sourceFileLineNumber_(err.sourceFileLineNumber_),
114 throwing_(err.throwing_),
129 const string& functionName
132 functionName_ = functionName;
133 sourceFileName_.clear();
134 sourceFileLineNumber_ = -1;
142 const char* functionName,
143 const char* sourceFileName,
144 const int sourceFileLineNumber
147 functionName_ = functionName;
148 sourceFileName_ = sourceFileName;
149 sourceFileLineNumber_ = sourceFileLineNumber;
157 const string& functionName,
158 const char* sourceFileName,
159 const int sourceFileLineNumber
164 functionName.c_str(),
173 if (!messageStreamPtr_->good())
176 <<
"error::operator OSstream&() : error stream has failed"
181 return *messageStreamPtr_;
189 string oneLineMessage(message());
190 oneLineMessage.replaceAll(
"\n",
" ");
192 errDict.add(
"type", word(
"Foam::error"));
193 errDict.add(
"message", oneLineMessage);
194 errDict.add(
"function", functionName());
195 errDict.add(
"sourceFile", sourceFileName());
196 errDict.add(
"sourceFileLineNumber", sourceFileLineNumber());
203 void Foam::error::exitOrAbort(
const int errNo,
const bool isAbort)
207 jobInfo.
add(
"FatalError",
operator dictionary());
218 if (throwing_ && !isAbort)
221 error errorException(*
this);
224 messageStreamPtr_->reset();
226 throw errorException;
231 <<
"\nFOAM aborting (FOAM_ABORT set)\n" <<
endl;
240 <<
"\nFOAM parallel run aborting\n" <<
endl;
247 <<
"\nFOAM parallel run exiting\n" <<
endl;
256 <<
"\nFOAM aborting\n" <<
endl;
268 <<
"\nFOAM exiting\n" <<
endl;
279 return messageStreamPtr_->str();
285 return messageStreamPtr_->reset();
291 exitOrAbort(errNo,
false);
297 exitOrAbort(1,
true);
309 if (includeTitle && !title().empty())
311 os << title().c_str()
321 os << message().c_str();
324 const label lineNo = sourceFileLineNumber();
326 if (
error::level >= 2 && lineNo && !functionName().empty())
329 <<
" From " << functionName().c_str() <<
nl;
331 if (!sourceFileName().empty())
333 os <<
" in file " << sourceFileName().c_str();
337 os <<
" at line " << lineNo <<
'.';
void exit()
End with "termination=exit".
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
static void printStack(Ostream &os)
Helper function to print a stack.
Class to handle messaging in a simple, consistent stream-based manner.
static bool & parRun()
Test if this a parallel run, or allow modify access.
static int level
The output level (verbosity) of messages.
Input/output from string buffers.
static void abort()
Call MPI_Abort with no other checks or cleanup.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A class for handling character strings derived from std::string.
static Switch find(const std::string &str)
string getEnv(const std::string &envName)
Get environment value for given envName.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
error(const string &title)
Construct from title string.
Generic output stream using a standard (STL) stream.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool bad() const
Return true if stream is corrupted.
string message() const
The accumulated error message.
static bool useAbort()
True if FOAM_ABORT is on.
errorManip< error > abort(error &err)
void exit(const int errNo=1)
Exit : can be called for any error to exit program.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const std::string version
OpenFOAM version (name or stringified number) as a std::string.
virtual ~error() noexcept
Destructor.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
static void warnAboutAge(const char *what, const int version)
Emit warning on stderr about something being old.
const std::string patch
OpenFOAM patch number as a std::string.
static bool constructed
Global value for constructed job info.
void abort()
Abort : used to stop code for fatal errors.
Output to string buffer, using a OSstream.
void clear() const
Clear any messages.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
void write(Ostream &os, const bool includeTitle=true) const
Print error message.
void abort()
End with "termination=abort".
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Class to handle errors and exceptions in a simple, consistent stream-based manner.
static void exit(int errNo=1)
Shutdown (finalize) MPI as required and exit program with errNo.