Cantera  2.3.0
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
CanteraError Class Reference

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

#include <ctexceptions.h>

Inheritance diagram for CanteraError:
[legend]

Public Member Functions

template<typename... Args>
 CanteraError (const std::string &procedure, const std::string &msg, const Args &... args)
 Normal Constructor for the CanteraError base class. More...
 
virtual ~CanteraError () throw ()
 Destructor for base class does nothing. More...
 
const char * what () const throw ()
 Get a description of the error. More...
 
void save ()
 Function to put this error onto Cantera's error stack. More...
 
virtual std::string getMessage () const
 Method overridden by derived classes to format the error message. More...
 
virtual std::string getClass () const
 Method overridden by derived classes to indicate their type. More...
 

Protected Member Functions

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

Protected Attributes

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

Private Attributes

std::string msg_
 Message associated with the exception. More...
 
bool saved_
 Exception has already been saved to Cantera's error stack. More...
 

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.

Constructor & Destructor Documentation

◆ CanteraError() [1/3]

CanteraError ( const std::string &  procedure,
const std::string &  msg,
const Args &...  args 
)
inline

Normal Constructor for the CanteraError base class.

Parameters
procedureString name for the function within which the error was generated.
msgDescriptive string describing the type of error message. This can be a fmt-style format string (i.e. 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 79 of file ctexceptions.h.

References CanteraError::msg_.

◆ ~CanteraError()

virtual ~CanteraError ( )
throw (
)
inlinevirtual

Destructor for base class does nothing.

Definition at line 92 of file ctexceptions.h.

◆ CanteraError() [2/3]

CanteraError ( )
inlineprotected

Protected default constructor discourages throwing errors containing no information.

Definition at line 112 of file ctexceptions.h.

◆ CanteraError() [3/3]

CanteraError ( const std::string &  procedure)
explicitprotected

Constructor used by derived classes that override getMessage()

Definition at line 19 of file ctexceptions.cpp.

Member Function Documentation

◆ what()

const char * what ( ) const
throw (
)

Get a description of the error.

Definition at line 34 of file ctexceptions.cpp.

References CanteraError::formattedMessage_, CanteraError::getClass(), CanteraError::getMessage(), and CanteraError::procedure_.

Referenced by FuncEval::eval_nothrow().

◆ save()

void save ( )

Function to put this error onto Cantera's error stack.

Deprecated:
Unused.

To be removed after Cantera 2.3.

Definition at line 25 of file ctexceptions.cpp.

References Application::addError(), CanteraError::getMessage(), Application::Instance(), CanteraError::procedure_, CanteraError::saved_, and Cantera::warn_deprecated().

◆ getMessage()

std::string getMessage ( ) const
virtual

Method overridden by derived classes to format the error message.

Reimplemented in IndexError, ArraySizeError, and XML_Error.

Definition at line 54 of file ctexceptions.cpp.

References CanteraError::msg_.

Referenced by ChemEquil::equilibrate(), FuncEval::eval_nothrow(), CanteraError::save(), and CanteraError::what().

◆ getClass()

virtual std::string getClass ( ) const
inlinevirtual

Method overridden by derived classes to indicate their type.

Reimplemented in NotImplementedError, IndexError, ArraySizeError, XML_NoChild, and XML_TagMismatch.

Definition at line 105 of file ctexceptions.h.

Referenced by CanteraError::what().

Member Data Documentation

◆ procedure_

std::string procedure_
protected

The name of the procedure where the exception occurred.

Definition at line 118 of file ctexceptions.h.

Referenced by CanteraError::save(), and CanteraError::what().

◆ formattedMessage_

std::string formattedMessage_
mutableprotected

Formatted message returned by what()

Definition at line 119 of file ctexceptions.h.

Referenced by CanteraError::what().

◆ msg_

std::string msg_
private

Message associated with the exception.

Definition at line 122 of file ctexceptions.h.

Referenced by CanteraError::CanteraError(), and CanteraError::getMessage().

◆ saved_

bool saved_
private

Exception has already been saved to Cantera's error stack.

Definition at line 123 of file ctexceptions.h.

Referenced by CanteraError::save().


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