76 - (12 * (version/100) + (version % 100))
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());
225void 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...
Input/output from string buffers.
bool bad() const noexcept
True if stream is corrupted.
void exit()
Job end with "exit" termination.
static void shutdown()
Simple shutdown (finalize) of JobInfo.
static bool constructed
Global value for constructed job info.
Generic output stream using a standard (STL) stream.
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static Switch find(const std::string &str)
static void abort()
Call MPI_Abort with no other checks or cleanup.
static bool & parRun() noexcept
Test if this a parallel run.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Class to handle errors and exceptions in a simple, consistent stream-based manner.
static void printStack(Ostream &os)
Helper function to print a stack.
OSstream & stream()
Return OSstream for output operations.
string message() const
The accumulated error message.
virtual void write(Ostream &os, const bool withTitle=true) const
Print error message.
void simpleExit(const int errNo, const bool isAbort)
Exit or abort, without throwing or job control handling.
static bool warnAboutAge(const int version) noexcept
Test if an age warning should be emitted.
static bool useAbort()
True if FOAM_ABORT is on.
void abort()
Abort : used to stop code for fatal errors.
virtual ~error() noexcept
Destructor.
void clear() const
Clear any messages.
friend Ostream & operator(Ostream &, const faMatrix< Type > &)
virtual bool write()
Write the output fields.
Handle output messages in a simple, consistent stream-based manner.
static int level
The output level (verbosity) of messages.
splitCell * master() const
A class for handling character strings derived from std::string.
A class for handling words, derived from Foam::string.
OBJstream os(runTime.globalPath()/outputName)
const std::string patch
OpenFOAM patch number as a std::string.
string getEnv(const std::string &envName)
Get environment value for given envName.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
constexpr char nl
The newline '\n' character (0x0a)