Go to the documentation of this file.
83 <<
" This " << what <<
" is very old.\n"
89 <<
" This " << what <<
" is " << months <<
" months old.\n"
111 functionName_(
"unknown"),
112 sourceFileName_(
"unknown"),
113 sourceFileLineNumber_(0),
123 functionName_(errDict.
get<
string>(
"functionName")),
124 sourceFileName_(errDict.
get<
string>(
"sourceFileName")),
125 sourceFileLineNumber_(errDict.
get<label>(
"sourceFileLineNumber")),
135 functionName_(err.functionName_),
136 sourceFileName_(err.sourceFileName_),
137 sourceFileLineNumber_(err.sourceFileLineNumber_),
138 throwing_(err.throwing_),
153 const string& functionName
156 functionName_ = functionName;
157 sourceFileName_.clear();
158 sourceFileLineNumber_ = -1;
166 const char* functionName,
167 const char* sourceFileName,
168 const int sourceFileLineNumber
171 functionName_.clear();
172 sourceFileName_.clear();
177 functionName_.assign(functionName);
182 sourceFileName_.assign(sourceFileName);
184 sourceFileLineNumber_ = sourceFileLineNumber;
186 return this->stream();
192 const string& functionName,
193 const char* sourceFileName,
194 const int sourceFileLineNumber
199 functionName.c_str(),
210 string oneLineMessage(message());
211 oneLineMessage.replaceAll(
"\n",
" ");
213 errDict.
add(
"type",
word(
"Foam::error"));
214 errDict.
add(
"message", oneLineMessage);
215 errDict.
add(
"function", functionName());
216 errDict.
add(
"sourceFile", sourceFileName());
217 errDict.
add(
"sourceFileLineNumber", sourceFileLineNumber());
225 void Foam::error::exiting(
const int errNo,
const bool isAbort)
232 error errorException(*
this);
235 messageStreamPtr_->reset();
237 throw errorException;
243 jobInfo.
add(
"FatalError",
operator dictionary());
247 simpleExit(errNo, isAbort);
258 <<
"\nFOAM aborting (FOAM_ABORT set)\n" <<
endl;
267 <<
"\nFOAM parallel run aborting\n" <<
endl;
274 <<
"\nFOAM parallel run exiting\n" <<
endl;
283 <<
"\nFOAM aborting\n" <<
endl;
295 <<
"\nFOAM exiting\n" <<
endl;
307 if (!messageStreamPtr_->good())
310 <<
"error::stream() : error stream has failed"
315 return *messageStreamPtr_;
321 return messageStreamPtr_->str();
327 return messageStreamPtr_->reset();
333 exiting(errNo,
false);
351 if (withTitle && !title().empty())
353 os << title().c_str()
363 os << message().c_str();
366 const label lineNo = sourceFileLineNumber();
368 if (
error::level >= 2 && lineNo && !functionName().empty())
371 <<
" From " << functionName().c_str() <<
nl;
373 if (!sourceFileName().empty())
375 os <<
" in file " << sourceFileName().c_str();
379 os <<
" at line " << lineNo <<
'.';
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.
A class for handling words, derived from Foam::string.
Handle output messages in a simple, consistent stream-based manner.
static int level
The output level (verbosity) of messages.
static bool master(const label communicator=worldComm)
Am I the master process.
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.
static void shutdown()
Simple shutdown (finalize) of JobInfo.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
OBJstream os(runTime.globalPath()/outputName)
bool bad() const noexcept
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.
OSstream & stream()
Return OSstream for output operations.
const std::string patch
OpenFOAM patch number as a std::string.
static bool constructed
Global value for constructed job info.
static bool & parRun() noexcept
Test if this a parallel run.
void abort()
Abort : used to stop code for fatal errors.
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
static bool master(const label communicator=-1)
void simpleExit(const int errNo, const bool isAbort)
Exit or abort, without throwing or job control handling.
void clear() const
Clear any messages.
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
static bool warnAboutAge(const int version) noexcept
Test if an age warning should be emitted.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual void write(Ostream &os, const bool withTitle=true) const
Print error message.
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.