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")),
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)
A class for handling words, derived from Foam::string.
Handle output messages in a simple, consistent stream-based manner.
static bool master(const label communicator=worldComm)
Input/output from string buffers.
Ostream & endl(Ostream &os)
A class for handling character strings derived from std::string.
static Switch find(const std::string &str)
string getEnv(const std::string &envName)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
error(const string &title)
Generic output stream using a standard (STL) stream.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
OBJstream os(runTime.globalPath()/outputName)
virtual bool write(const token &tok)=0
bool bad() const noexcept
errorManip< error > abort(error &err)
void exit(const int errNo=1)
errorManipArg< error, int > exit(error &err, const int errNo=1)
const std::string version
virtual ~error() noexcept
static bool & parRun() noexcept
static bool master(const label communicator=-1)
void simpleExit(const int errNo, const bool isAbort)
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
static bool warnAboutAge(const int version) noexcept
entry * add(entry *entryPtr, bool mergeEntry=false)
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
Class to handle errors and exceptions in a simple, consistent stream-based manner.
static void exit(int errNo=1)