Go to the documentation of this file.
51 <<
" This " << what <<
" is considered to be VERY old!\n"
64 <<
" This " << what <<
" is deemed to be " << months
79 functionName_(
"unknown"),
80 sourceFileName_(
"unknown"),
81 sourceFileLineNumber_(0),
82 throwExceptions_(false),
88 <<
"error::error(const string& title) : cannot open error stream"
99 functionName_(errDict.get<
string>(
"functionName")),
100 sourceFileName_(errDict.get<
string>(
"sourceFileName")),
101 sourceFileLineNumber_(errDict.get<
label>(
"sourceFileLineNumber")),
102 throwExceptions_(false),
108 <<
"error::error(const dictionary& errDict) : "
109 "cannot open error stream"
120 functionName_(err.functionName_),
121 sourceFileName_(err.sourceFileName_),
122 sourceFileLineNumber_(err.sourceFileLineNumber_),
123 throwExceptions_(err.throwExceptions_),
134 delete messageStreamPtr_;
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());
206 return messageStreamPtr_->str();
212 return messageStreamPtr_->reset();
224 if (
env(
"FOAM_ABORT"))
228 else if (throwExceptions_)
231 error errorException(*
this);
234 messageStreamPtr_->reset();
236 throw errorException;
241 <<
"\nFOAM parallel run exiting\n" <<
endl;
247 <<
"\nFOAM exiting\n" <<
endl;
261 if (
env(
"FOAM_ABORT"))
264 <<
"\nFOAM aborting (FOAM_ABORT set)\n" <<
endl;
268 else if (throwExceptions_)
271 error errorException(*
this);
274 messageStreamPtr_->reset();
276 throw errorException;
281 <<
"\nFOAM parallel run aborting\n" <<
endl;
288 <<
"\nFOAM aborting\n" <<
endl;
305 os << title().c_str() <<
nl;
307 os << message().c_str();
312 <<
" From function " << functionName().c_str() <<
nl
313 <<
" in file " << sourceFileName().c_str()
314 <<
" at line " << sourceFileLineNumber() <<
'.';
void exit()
End with "termination=exit".
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Class to handle messaging in a simple, consistent stream-based manner.
static void exit(int errnum=1)
Exit program.
static bool & parRun()
Is this a parallel run?
static int level
Controls the output verbosity of messageStream.
Input/output from string buffers.
static void abort()
Abort program.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A class for handling character strings derived from std::string.
bool env(const std::string &envName)
True if environment variable of given name is defined.
error(const string &title)
Construct from title string.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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.
prefixOSstream Perr
An Ostream wrapper for parallel output to std::cerr.
virtual ~error()
Destructor.
static void warnAboutAge(const char *what, const int version)
Emit warning on stderr about something being old.
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.
OStringStream * messageStreamPtr_
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,...
bool good() const
Return true if next operation might succeed.
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Ostream & operator<<(Ostream &, const boundaryPatch &)