69 template<
class EnumType>
class Enum;
77 public std::exception,
83 void exiting(
const int errNo,
const bool isAbort);
100 void simpleExit(
const int errNo,
const bool isAbort);
146 static
bool master(const label communicator = -1);
266 void exit(
const int errNo = 1);
273 virtual void write(
Ostream&
os,
const bool withTitle =
true)
const;
306 label ioStartLineNumber_;
307 label ioEndLineNumber_;
313 void exiting(
const int errNo,
const bool isAbort);
327 explicit IOerror(
const dictionary& errDict);
345 return ioStartLineNumber_;
351 return ioEndLineNumber_;
397 const std::string& where,
407 const std::string& where,
421 const std::string& msg
431 void exit(
const int errNo = 1);
437 virtual void write(
Ostream&
os,
const bool withTitle =
true)
const;
471 #define FatalErrorIn(functionName) \ 472 ::Foam::FatalError((functionName), __FILE__, __LINE__) 476 #define FatalErrorInFunction FatalErrorIn(FUNCTION_NAME) 480 #define FatalErrorInLookup(lookupTag, lookupName, lookupTable) \ 481 ::Foam::FatalError(FUNCTION_NAME, __FILE__, __LINE__) \ 482 << "Unknown " << (lookupTag) << " type " << (lookupName) \ 483 << "\n\nValid " << (lookupTag) << " types :\n" \ 484 << ((lookupTable).sortedToc()) << '\n' 490 #define FatalIOErrorIn(functionName, ios) \ 491 ::Foam::FatalIOError((functionName), __FILE__, __LINE__, (ios)) 496 #define FatalIOErrorInFunction(ios) FatalIOErrorIn(FUNCTION_NAME, ios) 501 #define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable) \ 502 ::Foam::FatalIOError(FUNCTION_NAME, __FILE__, __LINE__, (ios)) \ 503 << "Unknown " << (lookupTag) << " type " << (lookupName) \ 504 << "\n\nValid " << (lookupTag) << " types :\n" \ 505 << ((lookupTable).sortedToc()) << '\n' 512 #define SafeFatalIOErrorIn(functionName, ios, msg) \ 513 ::Foam::IOerror::SafeFatalIOError \ 514 ((functionName), __FILE__, __LINE__, (ios), (msg)) 520 #define SafeFatalIOErrorInFunction(ios, msg) \ 521 SafeFatalIOErrorIn(FUNCTION_NAME, ios, msg) 530 #define notImplemented(functionName) \ 531 FatalErrorIn(functionName) \ 532 << "Not implemented" << ::Foam::abort(FatalError); 540 #define NotImplemented notImplemented(FUNCTION_NAME) const string & title() const noexcept
The title of this error type.
IOerror(const char *title)
Construct from title string.
Generic output stream using a standard (STL) stream.
void clear() const
Clear any accumulated error messages.
std::unique_ptr< OStringStream > messageStreamPtr_
handlerTypes
Handling of errors. The exact handling depends on the local context.
void abort()
Abort : used to stop code for fatal errors.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
virtual ~IOerror() noexcept
Destructor.
bool throwing() const noexcept
Return the current exception throwing state (on or off)
bool dontThrowExceptions() noexcept
Deactivate exception throwing.
virtual ~error() noexcept
Destructor.
Handle output messages in a simple, consistent stream-based manner.
Default behaviour (local meaning)
void exit(const int errNo=1)
Exit : can be called for any error to exit program.
static bool warnAboutAge(const int version) noexcept
Test if an age warning should be emitted.
Class to handle errors and exceptions in a simple, consistent stream-based manner.
label sourceFileLineNumber_
static void safePrintStack(std::ostream &os, int size=-1)
Helper function to print a stack, with optional upper limit. Used when OpenFOAM IO not yet initialise...
static bool useAbort()
True if FOAM_ABORT is on.
static bool master(const label communicator=-1)
Like Pstream::master but with a Pstream::parRun guard in case Pstream has not yet been initialised...
const string & functionName() const noexcept
The currently defined function name for output messages.
string message() const
The accumulated error message.
void abort()
Abort : used to stop code for fatal errors.
virtual void write(Ostream &os, const bool withTitle=true) const
Print error message.
Ignore on errors/problems.
label sourceFileLineNumber() const noexcept
The currently defined source-file line number for output messages.
bool throwExceptions(const bool on=true) noexcept
Specify exception throwing state (default is on)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
void exit(const int errNo=1)
Exit : can be called for any error to exit program.
const string & ioFileName() const noexcept
The currently defined IO name for output messages.
label ioStartLineNumber() const noexcept
The currently defined IO start-line number for output messages.
OBJstream os(runTime.globalPath()/outputName)
OSstream & operator()()
Explicit convert to OSstream for << operations.
virtual void write(Ostream &os, const bool withTitle=true) const
Print error message.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
const std::string version
OpenFOAM version (name or stringified number) as a std::string.
An IOstream is an abstract base class for all input/output systems; be they streams, files, token lists etc.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
OSstream & stream()
Return OSstream for output operations.
const string & sourceFileName() const noexcept
The currently defined source-file name for output messages.
label ioEndLineNumber() const noexcept
The currently defined IO end-line number.
static void printStack(Ostream &os, int size=-1)
Helper function to print a stack, with optional upper limit.
static void SafeFatalIOError(const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const IOstream &ioStream, const std::string &msg)
Print basic message and exit.
Fatal on errors/problems.
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
error(const char *title)
Construct from title string.
static const Enum< handlerTypes > handlerNames
Names of the error handler types.
void simpleExit(const int errNo, const bool isAbort)
Exit or abort, without throwing or job control handling.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...