11#ifndef CT_CTEXCEPTIONS_H
12#define CT_CTEXCEPTIONS_H
82 template <
typename... Args>
83 CanteraError(
const string& procedure,
const string& msg,
const Args&... args)
86 if (
sizeof...(args) == 0) {
89 msg_ = fmt::format(msg, args...);
97 const char*
what()
const throw() override;
107 return "CanteraError";
152 return "ArraySizeError";
178 IndexError(
const string& func,
const string& arrayName,
size_t m,
size_t mmax) :
179 CanteraError(func), arrayName_(arrayName), m_(m), mmax_(mmax) {}
203 template <
typename... Args>
208 return "NotImplementedError";
213#define XSTR_TRACE_LINE(s) STR_TRACE_LINE(s)
216#define STR_TRACE_LINE(s) #s
222#define STR_TRACE (string(__FILE__) + ":" + XSTR_TRACE_LINE(__LINE__))
226# define AssertTrace(expr) ((void) (0))
229# define AssertThrow(expr, procedure) ((void) (0))
231#ifndef AssertThrowMsg
232# define AssertThrowMsg(expr,procedure, ...) ((void) (0))
247# define AssertTrace(expr) ((expr) ? (void) 0 : throw CanteraError(STR_TRACE, string("failed assert: ") + #expr))
261# define AssertThrow(expr, procedure) ((expr) ? (void) 0 : throw CanteraError(procedure, string("failed assert: ") + #expr))
277#ifndef AssertThrowMsg
278# define AssertThrowMsg(expr, procedure, ...) ((expr) ? (void) 0 : throw CanteraError(procedure + string(":\nfailed assert: \"") + string(#expr) + string("\""), __VA_ARGS__))
286# define AssertFinite(expr, procedure, ...) AssertThrowMsg(expr < BigNumber && expr > -BigNumber, procedure, __VA_ARGS__)
ArraySizeError(const string &procedure, size_t sz, size_t reqd)
Constructor.
string getMessage() const override
Method overridden by derived classes to format the error message.
string getClass() const override
Method overridden by derived classes to indicate their type.
Base class for exceptions thrown by Cantera classes.
const char * what() const override
Get a description of the error.
virtual string getMessage() const
Method overridden by derived classes to format the error message.
string formattedMessage_
Formatted message returned by what()
string procedure_
The name of the procedure where the exception occurred.
virtual ~CanteraError()
Destructor for base class does nothing.
CanteraError()
Protected default constructor discourages throwing errors containing no information.
string msg_
Message associated with the exception.
virtual string getMethod() const
Get the name of the method that threw the exception.
CanteraError(const string &procedure, const string &msg, const Args &... args)
Normal Constructor for the CanteraError base class.
virtual string getClass() const
Method overridden by derived classes to indicate their type.
An array index is out of range.
string getMessage() const override
Method overridden by derived classes to format the error message.
IndexError(const string &func, const string &arrayName, size_t m, size_t mmax)
Constructor.
string getClass() const override
Method overridden by derived classes to indicate their type.
An error indicating that an unimplemented function has been called.
NotImplementedError(const string &func, const string &msg, const Args &... args)
Alternative constructor taking same arguments as CanteraError.
NotImplementedError(const string &func)
string getClass() const override
Method overridden by derived classes to indicate their type.
This file contains definitions of constants, types and terms that are used in internal routines and a...
Wrapper for either system-installed or local headers for fmt.
Namespace for the Cantera kernel.