69template<
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
int communicator = -1);
159 static
bool warnAboutAge(const
char* what, const
int version);
196 bool throwing(
const bool on)
noexcept
261 void exit(
const int errNo = 1);
268 virtual void write(
Ostream&
os,
const bool withTitle =
true)
const;
301 label ioStartLineNumber_;
302 label ioEndLineNumber_;
308 void exiting(
const int errNo,
const bool isAbort);
340 return ioStartLineNumber_;
346 return ioEndLineNumber_;
392 const std::string& where,
402 const std::string& where,
416 const std::string& msg
426 void exit(
const int errNo = 1);
432 virtual void write(
Ostream&
os,
const bool withTitle =
true)
const;
466#define FatalErrorIn(functionName) \
467 ::Foam::FatalError((functionName), __FILE__, __LINE__)
471#define FatalErrorInFunction FatalErrorIn(FUNCTION_NAME)
475#define FatalErrorInLookup(lookupTag, lookupName, lookupTable) \
476 ::Foam::FatalError(FUNCTION_NAME, __FILE__, __LINE__) \
477 << "Unknown " << (lookupTag) << " type " << (lookupName) \
478 << "\n\nValid " << (lookupTag) << " types :\n" \
479 << ((lookupTable).sortedToc()) << '\n'
485#define FatalIOErrorIn(functionName, ios) \
486 ::Foam::FatalIOError((functionName), __FILE__, __LINE__, (ios))
491#define FatalIOErrorInFunction(ios) FatalIOErrorIn(FUNCTION_NAME, ios)
496#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable) \
497 ::Foam::FatalIOError(FUNCTION_NAME, __FILE__, __LINE__, (ios)) \
498 << "Unknown " << (lookupTag) << " type " << (lookupName) \
499 << "\n\nValid " << (lookupTag) << " types :\n" \
500 << ((lookupTable).sortedToc()) << '\n'
507#define SafeFatalIOErrorIn(functionName, ios, msg) \
508 ::Foam::IOerror::SafeFatalIOError \
509 ((functionName), __FILE__, __LINE__, (ios), (msg))
515#define SafeFatalIOErrorInFunction(ios, msg) \
516 SafeFatalIOErrorIn(FUNCTION_NAME, ios, msg)
525#define notImplemented(functionName) \
526 FatalErrorIn(functionName) \
527 << "Not implemented" << ::Foam::abort(FatalError);
535#define NotImplemented notImplemented(FUNCTION_NAME)
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
virtual ~IOerror() noexcept
Destructor.
IOerror(const char *title)
Construct from title string.
IOerror(const std::string &title)
Construct from title string.
label ioEndLineNumber() const noexcept
The currently defined IO end-line number.
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,...
Generic output stream using a standard (STL) stream.
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
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.
bool throwExceptions(const bool on=true) noexcept
Specify exception throwing state (default is on).
OSstream & stream()
Return OSstream for output operations.
error(const std::string &title)
Construct from title string.
static bool master(const int communicator=-1)
Like Pstream::master but with a Pstream::parRun guard in case Pstream has not yet been initialised.
bool dontThrowExceptions() noexcept
Deactivate exception throwing.
string message() const
The accumulated error message.
handlerTypes
Handling of errors. The exact handling depends on the local context.
@ WARN
Warn on errors/problems.
@ STRICT
Fatal on errors/problems.
@ DEFAULT
Default behaviour (local meaning).
@ IGNORE
Ignore on errors/problems.
std::unique_ptr< OStringStream > messageStreamPtr_
void exit(const int errNo=1)
Exit : can be called for any error to exit program.
void simpleExit(const int errNo, const bool isAbort)
Exit or abort, without throwing or job control handling.
static bool warnAboutAge(const int version) noexcept
Test if an age warning should be emitted.
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 void printStack(Ostream &os, int size=-1)
Helper function to print a stack, with optional upper limit.
static const Enum< handlerTypes > handlerNames
Names of the error handler types.
void abort()
Abort : used to stop code for fatal errors.
OSstream & operator()()
Explicit convert to OSstream for << operations.
virtual ~error() noexcept
Destructor.
error(const char *title)
Construct from title string.
void clear() const
Clear any accumulated error messages.
bool throwing() const noexcept
Return the current exception throwing state (on or off).
bool throwing(const bool on) noexcept
Specify exception throwing state (on or off).
int sourceFileLineNumber() const noexcept
The currently defined source-file line number for output messages.
int sourceFileLineNumber_
messageStream(errorSeverity severity, int maxErrors=0, bool use_stderr=false)
Construct untitled with given characteristics.
const string & title() const noexcept
The title of this error type.
OBJstream os(runTime.globalPath()/outputName)
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 ...
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...