Go to the documentation of this file.
40 functionName_(
"unknown"),
41 sourceFileName_(
"unknown"),
42 sourceFileLineNumber_(0),
43 throwExceptions_(false),
49 <<
"error::error(const string& title) : cannot open error stream"
60 functionName_(errDict.
lookup(
"functionName")),
61 sourceFileName_(errDict.
lookup(
"sourceFileName")),
62 sourceFileLineNumber_(
readLabel(errDict.
lookup(
"sourceFileLineNumber"))),
63 throwExceptions_(false),
69 <<
"error::error(const dictionary& errDict) : "
70 "cannot open error stream"
81 functionName_(err.functionName_),
82 sourceFileName_(err.sourceFileName_),
83 sourceFileLineNumber_(err.sourceFileLineNumber_),
84 throwExceptions_(err.throwExceptions_),
93 delete messageStreamPtr_;
99 const char* functionName,
100 const char* sourceFileName,
101 const int sourceFileLineNumber
104 functionName_ = functionName;
105 sourceFileName_ = sourceFileName;
106 sourceFileLineNumber_ = sourceFileLineNumber;
114 const string& functionName,
115 const char* sourceFileName,
116 const int sourceFileLineNumber
121 functionName.c_str(),
130 if (!messageStreamPtr_->good())
133 <<
"error::operator OSstream&() : error stream has failed"
138 return *messageStreamPtr_;
146 string oneLineMessage(message());
147 oneLineMessage.replaceAll(
'\n',
' ');
149 errDict.add(
"type", word(
"Foam::error"));
150 errDict.add(
"message", oneLineMessage);
151 errDict.add(
"function", functionName());
152 errDict.add(
"sourceFile", sourceFileName());
153 errDict.add(
"sourceFileLineNumber", sourceFileLineNumber());
161 return messageStreamPtr_->str();
173 if (
env(
"FOAM_ABORT"))
181 <<
"\nFOAM parallel run exiting\n" <<
endl;
186 if (throwExceptions_)
189 error errorException(*
this);
192 messageStreamPtr_->rewind();
194 throw errorException;
199 <<
"\nFOAM exiting\n" <<
endl;
214 if (
env(
"FOAM_ABORT"))
217 <<
"\nFOAM aborting (FOAM_ABORT set)\n" <<
endl;
225 <<
"\nFOAM parallel run aborting\n" <<
endl;
231 if (throwExceptions_)
234 error errorException(*
this);
237 messageStreamPtr_->rewind();
239 throw errorException;
244 <<
"\nFOAM aborting\n" <<
endl;
const string & sourceFileName() const
bool env(const word &)
Return true if environment variable of given name is defined.
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?
prefixOSstream Perr(cerr, "Perr")
const string & functionName() const
static void abort()
Abort program.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A class for handling character strings derived from std::string.
error(const string &title)
Construct from title string.
Ostream & operator<<(Ostream &, const edgeMesh &)
A list of keyword definitions, which are a keyword followed by any number of values (e....
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)
label sourceFileLineNumber() const
virtual ~error()
Destructor.
void abort()
Abort : used to stop code for fatal errors.
Output to memory buffer stream.
OStringStream * messageStreamPtr_
label readLabel(Istream &is)
const string & title() const
Return the title of this error type.
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.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
stressControl lookup("compactNormalStress") >> compactNormalStress