Go to the documentation of this file.
41 ioFileName_(
"unknown"),
42 ioStartLineNumber_(-1),
50 ioFileName_(errDict.get<
string>(
"ioFileName")),
51 ioStartLineNumber_(errDict.get<label>(
"ioStartLineNumber")),
52 ioEndLineNumber_(errDict.get<label>(
"ioEndLineNumber"))
66 const char* functionName,
67 const char* sourceFileName,
68 const int sourceFileLineNumber,
69 const string& ioFileName,
70 const label ioStartLineNumber,
71 const label ioEndLineNumber
75 ioFileName_ = ioFileName;
76 ioStartLineNumber_ = ioStartLineNumber;
77 ioEndLineNumber_ = ioEndLineNumber;
85 const char* functionName,
86 const char* sourceFileName,
87 const int sourceFileLineNumber,
105 const char* functionName,
106 const char* sourceFileName,
107 const int sourceFileLineNumber,
115 sourceFileLineNumber,
125 const char* functionName,
126 const char* sourceFileName,
127 const int sourceFileLineNumber,
138 sourceFileLineNumber,
146 <<
"--> FOAM FATAL IO ERROR:" <<
nl
148 <<
"file: " << ioStream.
name()
150 <<
" From " << functionName <<
nl
151 <<
" in file " << sourceFileName
152 <<
" at line " << sourceFileLineNumber <<
'.' <<
std::endl;
162 errDict.remove(
"type");
163 errDict.add(
"type",
word(
"Foam::IOerror"));
165 errDict.add(
"ioFileName", ioFileName());
166 errDict.add(
"ioStartLineNumber", ioStartLineNumber());
167 errDict.add(
"ioEndLineNumber", ioEndLineNumber());
175 void Foam::IOerror::exitOrAbort(
const int errNo,
const bool isAbort)
179 jobInfo.
add(
"FatalIOError",
operator dictionary());
190 if (throwing_ && !isAbort)
193 IOerror errorException(*
this);
196 messageStreamPtr_->reset();
198 throw errorException;
203 <<
"\nFOAM aborting (FOAM_ABORT set)\n" <<
endl;
212 <<
"\nFOAM parallel run aborting\n" <<
endl;
219 <<
"\nFOAM parallel run exiting\n" <<
endl;
228 <<
"\nFOAM aborting\n" <<
endl;
240 <<
"\nFOAM exiting\n" <<
endl;
251 exitOrAbort(1,
false);
257 exitOrAbort(1,
true);
269 if (includeTitle && !title().empty())
271 os << title().c_str()
281 os << message().c_str();
284 if (!ioFileName().empty())
287 <<
"file: " << ioFileName().c_str();
289 if (ioStartLineNumber() >= 0)
291 os <<
" at line " << ioStartLineNumber();
292 if (ioStartLineNumber() < ioEndLineNumber())
294 os <<
" to " << ioEndLineNumber();
301 const label lineNo = sourceFileLineNumber();
306 <<
" From " << functionName().c_str() <<
nl;
308 if (!sourceFileName().empty())
310 os <<
" in file " << sourceFileName().c_str();
314 os <<
" at line " << lineNo <<
'.';
void exit()
End with "termination=exit".
static void printStack(Ostream &os)
Helper function to print a stack.
void abort()
Abort : used to stop code for fatal errors.
A class for handling words, derived from Foam::string.
IOerror(const string &title)
Construct from title string.
static bool & parRun()
Test if this a parallel run, or allow modify access.
static int level
The output level (verbosity) of messages.
An IOstream is an abstract base class for all input/output systems; be they streams,...
Input/output from string buffers.
static void abort()
Call MPI_Abort with no other checks or cleanup.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A class for handling character strings derived from std::string.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
static void SafeFatalIOError(const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const IOstream &ioStream, const string &msg)
Print basic message and exit.
const fileName & name() const
The dictionary name.
label startLineNumber() const
Return line number of first token in dictionary.
label endLineNumber() const
Return line number of last token in dictionary.
virtual const fileName & name() const
Return the name of the stream.
Generic output stream using a standard (STL) stream.
virtual ~IOerror() noexcept
Destructor.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool bad() const
Return true if stream is corrupted.
static bool useAbort()
True if FOAM_ABORT is on.
errorManip< error > abort(error &err)
errorManipArg< error, int > exit(error &err, const int errNo=1)
OSstream & operator()()
Explicit convert to OSstream for << operations.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
void exit(const int errNo=1)
Exit : can be called for any error to exit program.
const std::string patch
OpenFOAM patch number as a std::string.
static bool constructed
Global value for constructed job info.
void write(Ostream &os, const bool includeTitle=true) const
Print error message.
label lineNumber() const
Const access to the current stream line number.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
void abort()
End with "termination=abort".
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Class to handle errors and exceptions in a simple, consistent stream-based manner.
static void exit(int errNo=1)
Shutdown (finalize) MPI as required and exit program with errNo.