Class to handle errors and exceptions in a simple, consistent stream-based manner. More...
Public Member Functions | |
error (const string &title) | |
error (const dictionary &errDict) | |
error (const error &err) | |
virtual | ~error () noexcept |
string | message () const |
void | clear () const |
const string & | functionName () const noexcept |
const string & | sourceFileName () const noexcept |
label | sourceFileLineNumber () const noexcept |
bool | throwing () const noexcept |
bool | throwing (const bool on) noexcept |
OSstream & | stream () |
operator OSstream & () | |
OSstream & | operator() () |
OSstream & | operator() (const string &functionName) |
OSstream & | operator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber=0) |
OSstream & | operator() (const string &functionName, const char *sourceFileName, const int sourceFileLineNumber=0) |
operator dictionary () const | |
void | exit (const int errNo=1) |
void | abort () |
virtual void | write (Ostream &os, const bool withTitle=true) const |
bool | throwExceptions (const bool on=true) noexcept |
bool | dontThrowExceptions () noexcept |
Static Public Member Functions | |
static bool | master (const label communicator=-1) |
static bool | warnAboutAge (const int version) noexcept |
static bool | warnAboutAge (const char *what, const int version) |
static void | safePrintStack (std::ostream &os) |
static void | printStack (Ostream &os) |
static bool | useAbort () |
Protected Member Functions | |
void | simpleExit (const int errNo, const bool isAbort) |
Protected Attributes | |
string | functionName_ |
string | sourceFileName_ |
label | sourceFileLineNumber_ |
bool | throwing_ |
std::unique_ptr< OStringStream > | messageStreamPtr_ |
Additional Inherited Members |
Class to handle errors and exceptions in a simple, consistent stream-based manner.
The error class is globally instantiated with a title string. Errors, messages and other data are piped to the messageStream class in the standard manner. Manipulators are supplied for exit and abort that may terminate the program or throw an exception depending on whether the exception handling has been switched on (off by default).
|
explicit |
|
protected |
Definition at line 246 of file error.C.
References Foam::abort(), UPstream::abort(), Foam::endl(), Foam::exit(), UPstream::exit(), Foam::nl, UPstream::parRun(), Foam::Perr, error::printStack(), and error::useAbort().
|
static |
Definition at line 34 of file error.C.
References UPstream::master(), and UPstream::parRun().
Referenced by Foam::expandLeadingTilde(), and Foam::warnCompatDegrees().
|
staticnoexcept |
Definition at line 48 of file error.C.
References Foam::foamVersion::api, and Foam::foamVersion::version.
Referenced by Foam::expandLeadingTilde(), and timeControl::read().
|
static |
Definition at line 55 of file error.C.
References Foam::foamVersion::api, Foam::endl(), and Foam::foamVersion::version.
Foam::string message | ( | ) | const |
Definition at line 312 of file error.C.
Referenced by snappyLayerDriver::addLayers(), and motionSmootherAlgo::checkMesh().
void clear | ( | ) | const |
Definition at line 318 of file error.C.
Referenced by motionSmootherAlgo::checkMesh().
|
inlinenoexcept |
Definition at line 147 of file error.H.
References error::functionName_.
|
inlinenoexcept |
Definition at line 153 of file error.H.
References error::sourceFileName_.
|
inlinenoexcept |
Definition at line 159 of file error.H.
References error::sourceFileLineNumber_.
|
inlinenoexcept |
Definition at line 165 of file error.H.
References error::throwing_.
Referenced by functionObjectList::end(), functionObjectList::execute(), if(), IOobjectList::IOobjectList(), functionObjectList::read(), and error::throwExceptions().
Definition at line 172 of file error.H.
References error::throwing_.
Foam::OSstream & stream | ( | ) |
Definition at line 297 of file error.C.
References Foam::abort(), Foam::endl(), Foam::nl, and Foam::Perr.
Referenced by error::operator OSstream &(), error::operator()(), and Time::readDict().
|
inline |
Definition at line 186 of file error.H.
References error::stream().
|
inline |
Definition at line 192 of file error.H.
References error::stream().
Foam::OSstream & operator() | ( | const string & | functionName | ) |
Foam::OSstream & operator() | ( | const char * | functionName, |
const char * | sourceFileName, | ||
const int | sourceFileLineNumber = 0 |
||
) |
Foam::OSstream & operator() | ( | const string & | functionName, |
const char * | sourceFileName, | ||
const int | sourceFileLineNumber = 0 |
||
) |
operator dictionary | ( | ) | const |
|
static |
Definition at line 25 of file dummyPrintStack.C.
|
static |
Definition at line 29 of file dummyPrintStack.C.
Referenced by UPstream::allToAll(), Foam::exitNow(), messageStream::masterStream(), Foam::reduce(), and error::simpleExit().
|
static |
Definition at line 91 of file error.C.
References Switch::find(), and Foam::getEnv().
Referenced by Foam::exitNow(), and error::simpleExit().
void exit | ( | const int | errNo = 1 | ) |
Definition at line 324 of file error.C.
Referenced by Foam::exit(), and if().
void abort | ( | ) |
Definition at line 330 of file error.C.
Referenced by Foam::abort().
Reimplemented in IOerror.
Definition at line 336 of file error.C.
References Foam::foamVersion::api, IOstream::bad(), messageStream::level, Foam::nl, os(), Foam::foamVersion::patch, and Foam::foamVersion::patched().
Referenced by functionObjectList::end(), functionObjectList::execute(), Foam::operator<<(), argList::parse(), and functionObjectList::read().
Definition at line 256 of file error.H.
References error::throwing().
Referenced by error::dontThrowExceptions().
|
inlinenoexcept |
Definition at line 263 of file error.H.
References error::throwExceptions().
|
protected |
Definition at line 84 of file error.H.
Referenced by error::functionName().
|
protected |
Definition at line 85 of file error.H.
Referenced by error::sourceFileName().
|
protected |
Definition at line 86 of file error.H.
Referenced by error::sourceFileLineNumber().
|
protected |
Definition at line 87 of file error.H.
Referenced by error::throwing().
|
protected |
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.