86 <<
" This " << what <<
" is very old.\n" 92 <<
" This " << what <<
" is " << months <<
" months old.\n" 114 functionName_(
"unknown"),
115 sourceFileName_(
"unknown"),
116 sourceFileLineNumber_(0),
126 functionName_(errDict.
get<
string>(
"functionName")),
128 sourceFileLineNumber_(errDict.
get<label>(
"sourceFileLineNumber")),
138 functionName_(err.functionName_),
139 sourceFileName_(err.sourceFileName_),
140 sourceFileLineNumber_(err.sourceFileLineNumber_),
141 throwing_(err.throwing_),
156 const string& functionName
159 functionName_ = functionName;
160 sourceFileName_.clear();
161 sourceFileLineNumber_ = -1;
169 const char* functionName,
170 const char* sourceFileName,
171 const int sourceFileLineNumber
174 functionName_.clear();
175 sourceFileName_.clear();
180 functionName_.assign(functionName);
185 sourceFileName_.assign(sourceFileName);
187 sourceFileLineNumber_ = sourceFileLineNumber;
189 return this->stream();
195 const string& functionName,
196 const char* sourceFileName,
197 const int sourceFileLineNumber
202 functionName.c_str(),
213 string oneLineMessage(message());
214 oneLineMessage.replaceAll(
"\n",
" ");
216 errDict.add(
"type", word(
"Foam::error"));
217 errDict.add(
"message", oneLineMessage);
218 errDict.add(
"function", functionName());
219 errDict.add(
"sourceFile", sourceFileName());
220 errDict.add(
"sourceFileLineNumber", sourceFileLineNumber());
228 void Foam::error::exiting(
const int errNo,
const bool isAbort)
235 error errorException(*
this);
238 messageStreamPtr_->reset();
240 throw errorException;
246 jobInfo.
add(
"FatalError",
operator dictionary());
250 simpleExit(errNo, isAbort);
261 <<
"\nFOAM aborting (FOAM_ABORT set)\n" <<
endl;
270 <<
"\nFOAM parallel run aborting\n" <<
endl;
277 <<
"\nFOAM parallel run exiting\n" <<
endl;
286 <<
"\nFOAM aborting\n" <<
endl;
298 <<
"\nFOAM exiting\n" <<
endl;
310 if (!messageStreamPtr_->good())
313 <<
"error::stream() : error stream has failed" 318 return *messageStreamPtr_;
324 return messageStreamPtr_->str();
330 return messageStreamPtr_->reset();
336 exiting(errNo,
false);
354 if (withTitle && !title().empty())
356 os << title().c_str()
366 os << message().c_str();
369 const label lineNo = sourceFileLineNumber();
371 if (
error::level >= 2 && lineNo && !functionName().empty())
374 <<
" From " << functionName().c_str() <<
nl;
376 if (!sourceFileName().empty())
378 os <<
" in file " << sourceFileName().c_str();
382 os <<
" at line " << lineNo <<
'.';
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
Generic output stream using a standard (STL) stream.
void clear() const
Clear any messages.
bool bad() const noexcept
True if stream is corrupted.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Input/output from string buffers.
constexpr char nl
The newline '\n' character (0x0a)
static void shutdown()
Simple shutdown (finalize) of JobInfo.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
virtual ~error() noexcept
Destructor.
bool patched()
Test if the patch string appears to be in use, which is when it is defined (non-zero).
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Handle output messages in a simple, consistent stream-based manner.
string getEnv(const std::string &envName)
Get environment value for given envName.
void exit(const int errNo=1)
Exit : can be called for any error to exit program.
static bool warnAboutAge(const int version) noexcept
Test if an age warning should be emitted.
error(const string &title)
Construct from title string.
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
static void exit(int errNo=1)
Shutdown (finalize) MPI as required and exit program with errNo.
static bool useAbort()
True if FOAM_ABORT is on.
static bool master(const label communicator=-1)
Like Pstream::master but with a Pstream::parRun guard in case Pstream has not yet been initialised...
string message() const
The accumulated error message.
void abort()
Abort : used to stop code for fatal errors.
virtual void write(Ostream &os, const bool withTitle=true) const
Print error message.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
errorManip< error > abort(error &err)
const int api
OpenFOAM api number (integer) corresponding to the value of OPENFOAM at the time of compilation...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
OBJstream os(runTime.globalPath()/outputName)
static void abort()
Call MPI_Abort with no other checks or cleanup.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
const std::string version
OpenFOAM version (name or stringified number) as a std::string.
OSstream & stream()
Return OSstream for output operations.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
const std::string patch
OpenFOAM patch number as a std::string.
static void printStack(Ostream &os, int size=-1)
Helper function to print a stack, with optional upper limit.
A class for handling character strings derived from std::string.
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
static Switch find(const std::string &str)
Find switchType for the given string, returning as a Switch that can be tested for good() or bad()...
static int level
The output level (verbosity) of messages.
static bool constructed
Global value for constructed job info.
void simpleExit(const int errNo, const bool isAbort)
Exit or abort, without throwing or job control handling.