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"
61 functionName_(errDict.lookup(
"functionName")),
62 sourceFileName_(errDict.lookup(
"sourceFileName")),
63 sourceFileLineNumber_(readLabel(errDict.lookup(
"sourceFileLineNumber"))),
64 abort_(
env(
"FOAM_ABORT")),
65 throwExceptions_(false),
71 <<
"error::error(const dictionary& errDict) : "
72 "cannot open error stream"
83 functionName_(err.functionName_),
84 sourceFileName_(err.sourceFileName_),
85 sourceFileLineNumber_(err.sourceFileLineNumber_),
87 throwExceptions_(err.throwExceptions_),
96 delete messageStreamPtr_;
102 const char* functionName,
103 const char* sourceFileName,
104 const int sourceFileLineNumber
107 functionName_ = functionName;
108 sourceFileName_ = sourceFileName;
109 sourceFileLineNumber_ = sourceFileLineNumber;
117 const string& functionName,
118 const char* sourceFileName,
119 const int sourceFileLineNumber
124 functionName.c_str(),
133 if (!messageStreamPtr_->good())
136 <<
"error::operator OSstream&() : error stream has failed"
141 return *messageStreamPtr_;
149 string oneLineMessage(message());
152 errDict.
add(
"type",
word(
"Foam::error"));
153 errDict.
add(
"message", oneLineMessage);
154 errDict.
add(
"function", functionName());
155 errDict.
add(
"sourceFile", sourceFileName());
156 errDict.
add(
"sourceFileLineNumber", sourceFileLineNumber());
164 return messageStreamPtr_->str();
184 <<
"\nFOAM parallel run exiting\n" <<
endl;
189 if (throwExceptions_)
192 error errorException(*
this);
195 messageStreamPtr_->rewind();
197 throw errorException;
202 <<
"\nFOAM exiting\n" <<
endl;
220 <<
"\nFOAM aborting (FOAM_ABORT set)\n" <<
endl;
228 <<
"\nFOAM parallel run aborting\n" <<
endl;
234 if (throwExceptions_)
237 error errorException(*
this);
240 messageStreamPtr_->rewind();
242 throw errorException;
247 <<
"\nFOAM aborting\n" <<
endl;