Cantera  3.1.0
Loading...
Searching...
No Matches
CanteraError Class Reference

Base class for exceptions thrown by Cantera classes. More...

#include <ctexceptions.h>

Inheritance diagram for CanteraError:
[legend]

Detailed Description

Base class for exceptions thrown by Cantera classes.

This class is the base class for exceptions thrown by Cantera. It inherits from std::exception so that normal error handling operations from applications may automatically handle the errors in their own way.

Definition at line 65 of file ctexceptions.h.

Public Member Functions

template<typename... Args>
 CanteraError (const string &procedure, const string &msg, const Args &... args)
 Normal Constructor for the CanteraError base class.
 
virtual ~CanteraError () throw ()
 Destructor for base class does nothing.
 
const char * what () const override throw ()
 Get a description of the error.
 
virtual string getMessage () const
 Method overridden by derived classes to format the error message.
 
virtual string getMethod () const
 Get the name of the method that threw the exception.
 
virtual string getClass () const
 Method overridden by derived classes to indicate their type.
 

Static Public Member Functions

static void setStackTraceDepth (int depth)
 Set the number of stack frames to include when a CanteraError is displayed.
 

Protected Member Functions

 CanteraError ()
 Protected default constructor discourages throwing errors containing no information.
 
 CanteraError (const string &procedure)
 Constructor used by derived classes that override getMessage()
 

Protected Attributes

string procedure_
 The name of the procedure where the exception occurred.
 
string formattedMessage_
 Formatted message returned by what()
 

Private Attributes

string msg_
 Message associated with the exception.
 
string traceback_
 Stack trace to location where exception was thrown.
 

Static Private Attributes

static int traceDepth_ = 0
 Number of stack frames to show. 0 to disable.
 

Constructor & Destructor Documentation

◆ CanteraError() [1/3]

template<typename... Args>
CanteraError ( const string &  procedure,
const string &  msg,
const Args &...  args 
)
inline

Normal Constructor for the CanteraError base class.

Parameters
procedureName of the function within which the error was generated. For member functions, this should be written as ClassName::functionName. For constructors, this should be ClassName::ClassName. Arguments can be specified to disambiguate overloaded functions, such as ClassName::functionName(int, int).
msgDescriptive string describing the type of error message. This can be a fmt-style format string (that is, using curly braces to indicate fields), which will be used with additional arguments to generate a formatted error message
argsArguments which will be used to interpolate the format string

Definition at line 83 of file ctexceptions.h.

◆ ~CanteraError()

virtual ~CanteraError ( )
throw (
)
inlinevirtual

Destructor for base class does nothing.

Definition at line 94 of file ctexceptions.h.

◆ CanteraError() [2/3]

CanteraError ( )
inlineprotected

Protected default constructor discourages throwing errors containing no information.

Definition at line 117 of file ctexceptions.h.

◆ CanteraError() [3/3]

CanteraError ( const string &  procedure)
explicitprotected

Constructor used by derived classes that override getMessage()

Definition at line 20 of file ctexceptions.cpp.

Member Function Documentation

◆ what()

const char * what ( ) const
throw (
)
override

Get a description of the error.

Definition at line 29 of file ctexceptions.cpp.

◆ getMessage()

string getMessage ( ) const
virtual

Method overridden by derived classes to format the error message.

Reimplemented in ArraySizeError, IndexError, and CallbackError.

Definition at line 52 of file ctexceptions.cpp.

◆ getMethod()

string getMethod ( ) const
virtual

Get the name of the method that threw the exception.

Definition at line 57 of file ctexceptions.cpp.

◆ getClass()

virtual string getClass ( ) const
inlinevirtual

Method overridden by derived classes to indicate their type.

Reimplemented in InputFileError, ArraySizeError, IndexError, NotImplementedError, and CallbackError.

Definition at line 106 of file ctexceptions.h.

◆ setStackTraceDepth()

void setStackTraceDepth ( int  depth)
static

Set the number of stack frames to include when a CanteraError is displayed.

By default, or if the depth is set to 0, no stack information will be shown.

Definition at line 62 of file ctexceptions.cpp.

Member Data Documentation

◆ procedure_

string procedure_
protected

The name of the procedure where the exception occurred.

Definition at line 123 of file ctexceptions.h.

◆ formattedMessage_

string formattedMessage_
mutableprotected

Formatted message returned by what()

Definition at line 124 of file ctexceptions.h.

◆ msg_

string msg_
private

Message associated with the exception.

Definition at line 127 of file ctexceptions.h.

◆ traceback_

string traceback_
private

Stack trace to location where exception was thrown.

Definition at line 129 of file ctexceptions.h.

◆ traceDepth_

int traceDepth_ = 0
staticprivate

Number of stack frames to show. 0 to disable.

Definition at line 130 of file ctexceptions.h.


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