IOerror Class Reference

Report an I/O error. More...

Inheritance diagram for IOerror:
Collaboration diagram for IOerror:

Public Member Functions

 IOerror (const string &title)
 Construct from title string. More...
 
 IOerror (const dictionary &errDict)
 Construct from dictionary. More...
 
virtual ~IOerror () noexcept
 Destructor. More...
 
const stringioFileName () const noexcept
 The currently defined IO name for output messages. More...
 
label ioStartLineNumber () const noexcept
 The currently defined IO start-line number for output messages. More...
 
label ioEndLineNumber () const noexcept
 The currently defined IO end-line number. More...
 
OSstreamoperator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const string &ioFileName, const label ioStartLineNumber=-1, const label ioEndLineNumber=-1)
 Define basic print message. More...
 
OSstreamoperator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const IOstream &ioStream)
 Define basic print message for IO stream. More...
 
OSstreamoperator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const dictionary &dict)
 Define basic print message for dictionary entries. Uses the dictionary::relativeName() on output. More...
 
OSstreamoperator() (const std::string &where, const IOstream &ioStream)
 Define basic print message for IO stream, independent of a source-file reference. Uses the dictionary::relativeName() on output. More...
 
OSstreamoperator() (const std::string &where, const dictionary &dict)
 Define basic print message for dictionary entries, independent of a source-file reference. Uses the dictionary::relativeName() on output. More...
 
 operator dictionary () const
 Extract a dictionary representation of the error information. 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...
 
virtual void write (Ostream &os, const bool withTitle=true) const
 Print error message. More...
 
- Public Member Functions inherited from error
 error (const string &title)
 Construct from title string. More...
 
 error (const dictionary &errDict)
 Construct from dictionary. More...
 
 error (const error &err)
 Copy construct. More...
 
virtual ~error () noexcept
 Destructor. More...
 
string message () const
 The accumulated error message. More...
 
void clear () const
 Clear any messages. More...
 
const stringfunctionName () const noexcept
 The currently defined function name for output messages. More...
 
const stringsourceFileName () const noexcept
 The currently defined source-file name for output messages. More...
 
label sourceFileLineNumber () const noexcept
 The currently defined source-file line number for output messages. More...
 
bool throwing () const noexcept
 Return the current exception throwing state (on or off) More...
 
bool throwing (const bool on) noexcept
 Specify exception throwing state (on or off) More...
 
OSstreamstream ()
 Return OSstream for output operations. More...
 
 operator OSstream & ()
 Implicit cast to OSstream for << operations. More...
 
OSstreamoperator() ()
 Explicit convert to OSstream for << operations. More...
 
OSstreamoperator() (const string &functionName)
 Define basic print message. More...
 
OSstreamoperator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber=0)
 Define basic print message. More...
 
OSstreamoperator() (const string &functionName, const char *sourceFileName, const int sourceFileLineNumber=0)
 Define basic print message. More...
 
 operator dictionary () const
 Extract a dictionary representation of the error information. 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...
 
bool throwExceptions (const bool on=true) noexcept
 Specify exception throwing state (default is on) More...
 
bool dontThrowExceptions () noexcept
 Deactivate exception throwing. More...
 
- Public Member Functions inherited from messageStream
 messageStream (const string &title, const errorSeverity severity, const int maxErrors=0)
 Construct from components. More...
 
 messageStream (const dictionary &dict)
 Construct as Fatal from dictionary, extracting the 'title'. More...
 
const stringtitle () const noexcept
 The title of this error type. More...
 
int maxErrors () const noexcept
 The maximum number of errors before program termination. More...
 
int maxErrors (int nErrors) noexcept
 Set the maximum number of errors before program termination. More...
 
OSstreamstream (OSstream *alternative=nullptr)
 Return OSstream for output operations. Use the alternative stream for serial-only output if it is a valid pointer. More...
 
OSstreammasterStream (const label communicator)
 Return OSstream for output operations on the master process only, Snull on other processes. More...
 
std::ostream & stdStream ()
 Return std::ostream for output operations. More...
 
OSstreamdeprecated (const int afterVersion, const char *functionName, const char *sourceFileName, const int sourceFileLineNumber=0)
 Report deprecation (after specified API version) with 'From function-name, source file, line number'. More...
 
 operator OSstream & ()
 Implicit cast to OSstream for << operations. More...
 
OSstreamoperator() ()
 Explicitly convert to OSstream for << operations. More...
 
OSstreamoperator() (const std::string &functionName)
 Report 'From function-name'. More...
 
OSstreamoperator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber=0)
 Report 'From function-name, source file, line number'. More...
 
OSstreamoperator() (const std::string &functionName, const char *sourceFileName, const int sourceFileLineNumber=0)
 Report 'From function-name, source file, line number'. More...
 
OSstreamoperator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const std::string &ioFileName, const label ioStartLineNumber=-1, const label ioEndLineNumber=-1)
 Report 'From function-name, source file, line number' as well as io-file name and location. More...
 
OSstreamoperator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const IOstream &)
 Report 'From function-name, source file, line number' as well as io-file name and location. More...
 
OSstreamoperator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const dictionary &)
 Report 'From function-name, source file, line number' as well as io-file name and location. More...
 

Static Public Member Functions

static void SafeFatalIOError (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const IOstream &ioStream, const string &msg)
 Print basic message and exit. More...
 
- Static Public Member Functions inherited from error
static bool master (const label communicator=-1)
 Like Pstream::master but with a Pstream::parRun guard in case Pstream has not yet been initialised. More...
 
static bool warnAboutAge (const int version) noexcept
 Test if an age warning should be emitted. More...
 
static bool warnAboutAge (const char *what, const int version)
 Emit warning on stderr about something being old. More...
 
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 initialised. More...
 
static void printStack (Ostream &os, int size=-1)
 Helper function to print a stack, with optional upper limit. More...
 
static bool useAbort ()
 True if FOAM_ABORT is on. More...
 

Additional Inherited Members

- Public Types inherited from error
enum  handlerTypes : char { DEFAULT = 0, IGNORE, WARN, STRICT }
 Handling of errors. The exact handling depends on the local context. More...
 
- Public Types inherited from messageStream
enum  errorSeverity {
  INFO = 1, INFO_STDERR, WARNING, SERIOUS,
  FATAL
}
 Message type, error severity flags. More...
 
- Static Public Attributes inherited from error
static const Enum< handlerTypeshandlerNames
 Names of the error handler types. More...
 
- Static Public Attributes inherited from messageStream
static int level
 The output level (verbosity) of messages. More...
 
static int redirect
 The output redirection of messages. More...
 
- Protected Member Functions inherited from error
void simpleExit (const int errNo, const bool isAbort)
 Exit or abort, without throwing or job control handling. More...
 
- Protected Attributes inherited from error
string functionName_
 
string sourceFileName_
 
label sourceFileLineNumber_
 
bool throwing_
 
std::unique_ptr< OStringStreammessageStreamPtr_
 
- Protected Attributes inherited from messageStream
string title_
 
errorSeverity severity_
 
int maxErrors_
 
int errorCount_
 

Detailed Description

Report an I/O error.

Definition at line 370 of file error.H.

Constructor & Destructor Documentation

◆ IOerror() [1/2]

IOerror ( const string title)
explicit

Construct from title string.

Definition at line 34 of file IOerror.C.

◆ IOerror() [2/2]

IOerror ( const dictionary errDict)
explicit

Construct from dictionary.

Definition at line 43 of file IOerror.C.

◆ ~IOerror()

~IOerror ( )
virtualnoexcept

Destructor.

Definition at line 54 of file IOerror.C.

Member Function Documentation

◆ ioFileName()

const string& ioFileName ( ) const
inlinenoexcept

The currently defined IO name for output messages.

Definition at line 415 of file error.H.

◆ ioStartLineNumber()

label ioStartLineNumber ( ) const
inlinenoexcept

The currently defined IO start-line number for output messages.

Definition at line 423 of file error.H.

◆ ioEndLineNumber()

label ioEndLineNumber ( ) const
inlinenoexcept

The currently defined IO end-line number.

Definition at line 431 of file error.H.

◆ operator()() [1/5]

Foam::OSstream & operator() ( const char *  functionName,
const char *  sourceFileName,
const int  sourceFileLineNumber,
const string ioFileName,
const label  ioStartLineNumber = -1,
const label  ioEndLineNumber = -1 
)

Define basic print message.

Returns
OSstream for further operations

Definition at line 61 of file IOerror.C.

References os().

Here is the call graph for this function:

◆ operator()() [2/5]

Foam::OSstream & operator() ( const char *  functionName,
const char *  sourceFileName,
const int  sourceFileLineNumber,
const IOstream ioStream 
)

Define basic print message for IO stream.

Returns
OSstream for further operations

Definition at line 86 of file IOerror.C.

◆ operator()() [3/5]

Foam::OSstream & operator() ( const char *  functionName,
const char *  sourceFileName,
const int  sourceFileLineNumber,
const dictionary dict 
)

Define basic print message for dictionary entries. Uses the dictionary::relativeName() on output.

Returns
OSstream for further operations

Definition at line 106 of file IOerror.C.

References dict, dictionary::endLineNumber(), dictionary::relativeName(), and dictionary::startLineNumber().

Here is the call graph for this function:

◆ operator()() [4/5]

Foam::OSstream & operator() ( const std::string &  where,
const IOstream ioStream 
)

Define basic print message for IO stream, independent of a source-file reference. Uses the dictionary::relativeName() on output.

Returns
OSstream for further operations

Definition at line 126 of file IOerror.C.

◆ operator()() [5/5]

Foam::OSstream & operator() ( const std::string &  where,
const dictionary dict 
)

Define basic print message for dictionary entries, independent of a source-file reference. Uses the dictionary::relativeName() on output.

Returns
OSstream for further operations

Definition at line 144 of file IOerror.C.

References dict, dictionary::endLineNumber(), dictionary::relativeName(), and dictionary::startLineNumber().

Here is the call graph for this function:

◆ SafeFatalIOError()

void SafeFatalIOError ( const char *  functionName,
const char *  sourceFileName,
const int  sourceFileLineNumber,
const IOstream ioStream,
const string msg 
)
static

Print basic message and exit.

Uses cerr if streams not yet constructed (at startup). Use in startup parsing instead of FatalError.

Definition at line 162 of file IOerror.C.

References JobInfo::constructed, Foam::endl(), Foam::exit(), Foam::FatalIOError, IOstream::lineNumber(), Foam::nl, and IOstream::relativeName().

Here is the call graph for this function:

◆ operator dictionary()

operator dictionary ( ) const

Extract a dictionary representation of the error information.

◆ exit()

void exit ( const int  errNo = 1)

Exit : can be called for any error to exit program.

Definition at line 239 of file IOerror.C.

Referenced by Foam::exit(), IFstream::operator()(), and Istream::operator()().

Here is the caller graph for this function:

◆ abort()

void abort ( )

Abort : used to stop code for fatal errors.

Definition at line 245 of file IOerror.C.

Referenced by Foam::abort().

Here is the caller graph for this function:

◆ write()

void write ( Ostream os,
const bool  withTitle = true 
) const
virtual

Print error message.

Reimplemented from error.

Definition at line 251 of file IOerror.C.

References Foam::foamVersion::api, IOstream::bad(), messageStream::level, Foam::nl, os(), Foam::foamVersion::patch, and Foam::foamVersion::patched().

Referenced by Foam::operator<<().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: