Class to handle errors and exceptions in a simple, consistent stream-based manner. More...
Public Member Functions | |
error (const string &title) | |
Construct from title string. More... | |
error (const dictionary &) | |
Construct from dictionary. More... | |
error (const error &) | |
Construct as copy. More... | |
virtual | ~error () throw () |
Destructor. More... | |
string | message () const |
const string & | functionName () const |
const string & | sourceFileName () const |
label | sourceFileLineNumber () const |
void | throwExceptions () |
void | dontThrowExceptions () |
OSstream & | operator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber=0) |
Convert to OSstream. More... | |
OSstream & | operator() (const string &functionName, const char *sourceFileName, const int sourceFileLineNumber=0) |
Convert to OSstream. More... | |
operator OSstream & () | |
Convert to OSstream. More... | |
OSstream & | operator() () |
Explicitly convert to OSstream for << operations. More... | |
operator dictionary () const | |
Create and return a dictionary. More... | |
void | exit (const int errNo=1) |
Exit : can be called for any error to exit program. More... | |
void | abort () |
Abort : used to stop code for fatal errors. More... | |
Static Public Member Functions | |
static void | safePrintStack (std::ostream &) |
Helper function to print a stack (if OpenFOAM IO not yet. More... | |
static void | printStack (Ostream &) |
Helper function to print a stack. More... | |
Protected Attributes | |
string | functionName_ |
string | sourceFileName_ |
label | sourceFileLineNumber_ |
bool | throwExceptions_ |
OStringStream * | messageStreamPtr_ |
Friends | |
Ostream & | operator<< (Ostream &, const error &) |
Additional Inherited Members | |
Severity flags. More... |
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 which may terminate the program or throw an exception depending on whether the exception handling has been switched on (off by default).
Construct from title string.
Definition at line 36 of file error.C.
References Foam::endl(), error::exit(), IOstream::good(), error::messageStreamPtr_, and Foam::Perr.
error | ( | const dictionary & | errDict | ) |
Construct from dictionary.
Definition at line 56 of file error.C.
References Foam::endl(), error::exit(), IOstream::good(), error::messageStreamPtr_, and Foam::Perr.
Foam::string message | ( | ) | const |
Definition at line 159 of file error.C.
Referenced by doCommand(), and Foam::operator<<().
|
inline |
Definition at line 106 of file error.H.
References error::functionName_.
Referenced by Foam::operator<<().
|
inline |
Definition at line 111 of file error.H.
References error::sourceFileName_.
Referenced by Foam::operator<<().
|
inline |
Definition at line 116 of file error.H.
References error::sourceFileLineNumber_.
Referenced by Foam::operator<<().
|
inline |
Definition at line 121 of file error.H.
References error::throwExceptions_.
Referenced by main(), Foam::tryCalc(), calcType::tryCalc(), calcType::tryInit(), calcType::tryPostCalc(), and calcType::tryPreCalc().
|
inline |
Definition at line 126 of file error.H.
References error::throwExceptions_.
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 OSstream & | ( | ) |
|
inline |
Explicitly convert to OSstream for << operations.
Definition at line 154 of file error.H.
Referenced by IOerror::operator()().
operator dictionary | ( | ) | const |
Create and return a dictionary.
|
static |
Helper function to print a stack (if OpenFOAM IO not yet.
initialised)
Definition at line 192 of file printStack.C.
References Foam::endl().
|
static |
Helper function to print a stack.
Definition at line 30 of file dummyPrintStack.C.
Referenced by messageStream::masterStream(), and Foam::reduce().
void exit | ( | const int | errNo = 1 | ) |
Exit : can be called for any error to exit program.
Prints stack before exiting.
Definition at line 165 of file error.C.
References Foam::abort(), dictionary::add(), JobInfo::constructed, Foam::endl(), Foam::env(), JobInfo::exit(), Foam::exit(), UPstream::exit(), Foam::jobInfo, UPstream::parRun(), and Foam::Perr.
Referenced by argList::argList(), error::error(), Foam::exit(), if(), argList::parse(), argList::setOption(), and argList::unsetOption().
void abort | ( | ) |
Abort : used to stop code for fatal errors.
Prints stack before exiting.
Definition at line 206 of file error.C.
References JobInfo::abort(), Foam::abort(), UPstream::abort(), dictionary::add(), JobInfo::constructed, Foam::endl(), Foam::env(), Foam::exit(), Foam::jobInfo, UPstream::parRun(), and Foam::Perr.
Referenced by Foam::abort().
|
protected |
Definition at line 76 of file error.H.
Referenced by error::functionName().
|
protected |
Definition at line 77 of file error.H.
Referenced by error::sourceFileName().
|
protected |
Definition at line 78 of file error.H.
Referenced by error::sourceFileLineNumber().
|
protected |
Definition at line 80 of file error.H.
Referenced by error::dontThrowExceptions(), and error::throwExceptions().
|
protected |
Definition at line 81 of file error.H.
Referenced by error::error().
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.