40 functionName_(
"unknown"),
41 sourceFileName_(
"unknown"),
42 sourceFileLineNumber_(0),
43 abort_(
env(
"FOAM_ABORT")),
44 throwExceptions_(false),
50 <<
"error::error(const string& title) : cannot open error stream"
60 const char* sourceFileName,
61 const int sourceFileLineNumber
65 sourceFileName_ = sourceFileName;
66 sourceFileLineNumber_ = sourceFileLineNumber;
75 const char* sourceFileName,
76 const int sourceFileLineNumber
90 if (!messageStream_.good())
93 <<
"error::operator OSstream&() : error stream has failed"
98 return messageStream_;
106 string oneLineMessage(message());
107 oneLineMessage.replaceAll(
'\n',
' ');
109 errDict.
add(
"type",
word(
"Foam::error"));
110 errDict.
add(
"message", oneLineMessage);
112 errDict.
add(
"sourceFile", sourceFileName());
113 errDict.
add(
"sourceFileLineNumber", sourceFileLineNumber());
121 return messageStream_.str();
141 <<
"\nFOAM parallel run exiting\n" <<
endl;
146 if (throwExceptions_)
149 error errorException(*
this);
152 messageStream_.rewind();
154 throw errorException;
159 <<
"\nFOAM exiting\n" <<
endl;
177 <<
"\nFOAM aborting (FOAM_ABORT set)\n" <<
endl;
185 <<
"\nFOAM parallel run aborting\n" <<
endl;
191 if (throwExceptions_)
194 error errorException(*
this);
197 messageStream_.rewind();
199 throw errorException;
204 <<
"\nFOAM aborting\n" <<
endl;
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
bool good() const
Return true if next operation might succeed.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static void abort()
Abort program.
static bool & parRun()
Is this a parallel run?
static void exit(int errnum=1)
Exit program.
A list of keyword definitions, which are a keyword followed by any number of values (e....
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Class to handle errors and exceptions in a simple, consistent stream-based manner.
const string & sourceFileName() const
OStringStream messageStream_
const string & functionName() const
void exit(const int errNo=1)
Exit : can be called for any error to exit program.
error(const string &title)
Construct from title string.
OSstream & operator()()
Explicitly convert to OSstream for << operations.
void abort()
Abort : used to stop code for fatal errors.
label sourceFileLineNumber() const
A functionName is a word starting with '#'.
Class to handle messaging in a simple, consistent stream-based manner.
const string & title() const
Return the title of this error type.
A class for handling character strings derived from std::string.
A class for handling words, derived from string.
errorManipArg< error, int > exit(error &err, const int errNo=1)
prefixOSstream Perr(cerr, "Perr")
bool env(const word &)
Return true if environment variable of given name is defined.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)