44 ioFileName_(
"unknown"),
45 ioStartLineNumber_(-1),
53 ioFileName_(errDict.get<
string>(
"ioFileName")),
54 ioStartLineNumber_(errDict.get<label>(
"ioStartLineNumber")),
55 ioEndLineNumber_(errDict.get<label>(
"ioEndLineNumber"))
69 const char* functionName,
70 const char* sourceFileName,
71 const int sourceFileLineNumber,
73 const label ioStartLineNumber,
74 const label ioEndLineNumber
84 ioFileName_ = std::move(ioFileName);
94 const char* functionName,
95 const char* sourceFileName,
96 const int sourceFileLineNumber,
104 sourceFileLineNumber,
105 ioStream.relativeName(),
106 ioStream.lineNumber(),
114 const char* functionName,
115 const char* sourceFileName,
116 const int sourceFileLineNumber,
124 sourceFileLineNumber,
126 dict.startLineNumber(),
134 const std::string& where,
143 ioStream.relativeName(),
144 ioStream.lineNumber(),
152 const std::string& where,
162 dict.startLineNumber(),
170 const char* functionName,
171 const char* sourceFileName,
172 const int sourceFileLineNumber,
174 const std::string& msg
183 sourceFileLineNumber,
192 <<
"--> FOAM FATAL IO ERROR:" <<
nl
196 <<
" From " << functionName <<
nl
197 <<
" in file " << sourceFileName
198 <<
" at line " << sourceFileLineNumber <<
'.' << std::endl;
204Foam::IOerror::operator Foam::dictionary()
const
208 errDict.add(
"type",
word(
"Foam::IOerror"),
true);
209 errDict.add(
"ioFileName", ioFileName());
210 errDict.add(
"ioStartLineNumber", ioStartLineNumber());
211 errDict.add(
"ioEndLineNumber", ioEndLineNumber());
219void Foam::IOerror::exiting(
const int errNo,
const bool isAbort)
231 throw errorException;
267 if (withTitle && !title().empty())
269 os << title().c_str()
279 os << message().c_str();
282 if (!ioFileName().empty())
285 <<
"file: " << ioFileName().c_str();
287 if (ioStartLineNumber() >= 0)
289 os <<
" at line " << ioStartLineNumber();
290 if (ioStartLineNumber() < ioEndLineNumber())
292 os <<
" to " << ioEndLineNumber();
299 const auto lineNo = sourceFileLineNumber();
304 <<
" From " << functionName().c_str() <<
nl;
306 if (!sourceFileName().empty())
308 os <<
" in file " << sourceFileName().c_str();
312 os <<
" at line " << lineNo <<
'.';
Input/output from string buffers.
virtual ~IOerror() noexcept
Destructor.
IOerror(const char *title)
Construct from title string.
label ioEndLineNumber() const noexcept
The currently defined IO end-line number.
virtual void write(Ostream &os, const bool withTitle=true) const
Print error message.
void exit(const int errNo=1)
Exit : can be called for any error to exit program.
label ioStartLineNumber() const noexcept
The currently defined IO start-line number for output messages.
void abort()
Abort : used to stop code for fatal errors.
const string & ioFileName() const noexcept
The currently defined IO name for output messages.
static void SafeFatalIOError(const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const IOstream &ioStream, const std::string &msg)
Print basic message and exit.
An IOstream is an abstract base class for all input/output systems; be they streams,...
label lineNumber() const noexcept
Const access to the current stream line number.
fileName relativeName() const
Return the name of the stream relative to the current case.
static void shutdown()
Simple shutdown (finalize) of JobInfo.
static bool constructed
Global value for constructed job info.
Generic output stream using a standard (STL) stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Class to handle errors and exceptions in a simple, consistent stream-based manner.
const string & sourceFileName() const noexcept
The currently defined source-file name for output messages.
const string & functionName() const noexcept
The currently defined function name for output messages.
string message() const
The accumulated error message.
void simpleExit(const int errNo, const bool isAbort)
Exit or abort, without throwing or job control handling.
static bool useAbort()
True if FOAM_ABORT is on.
error(const char *title)
Construct from title string.
void clear() const
Clear any accumulated error messages.
int sourceFileLineNumber() const noexcept
The currently defined source-file line number for output messages.
static int level
The output level (verbosity) of messages.
const string & title() const noexcept
The title of this error type.
A class for handling character strings derived from std::string.
A class for handling words, derived from Foam::string.
OBJstream os(runTime.globalPath()/outputName)
const std::string patch
OpenFOAM patch number as a std::string.
const int api
OpenFOAM api number (integer) corresponding to the value of OPENFOAM at the time of compilation.
bool patched()
Test if the patch string appears to be in use, which is when it is defined (non-zero).
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).