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(fmt::runtime(msg), args...);
97 const char*
what()
const throw() override;
107 return "CanteraError";
159 return "ArraySizeError";
185 IndexError(
const string& func,
const string& arrayName,
size_t m,
size_t mmax) :
186 CanteraError(func), arrayName_(arrayName), m_(m), mmax_(mmax) {}
210 template <
typename... Args>
215 return "NotImplementedError";
220#define XSTR_TRACE_LINE(s) STR_TRACE_LINE(s)
223#define STR_TRACE_LINE(s) #s
229#define STR_TRACE (string(__FILE__) + ":" + XSTR_TRACE_LINE(__LINE__))
233# define AssertTrace(expr) ((void) (0))
236# define AssertThrow(expr, procedure) ((void) (0))
238#ifndef AssertThrowMsg
239# define AssertThrowMsg(expr,procedure, ...) ((void) (0))
254# define AssertTrace(expr) ((expr) ? (void) 0 : throw CanteraError(STR_TRACE, string("failed assert: ") + #expr))
268# define AssertThrow(expr, procedure) ((expr) ? (void) 0 : throw CanteraError(procedure, string("failed assert: ") + #expr))
284#ifndef AssertThrowMsg
285# define AssertThrowMsg(expr, procedure, ...) ((expr) ? (void) 0 : throw CanteraError(procedure + string(":\nfailed assert: \"") + string(#expr) + string("\""), __VA_ARGS__))
293# 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.
string traceback_
Stack trace to location where exception was thrown.
virtual string getMessage() const
Method overridden by derived classes to format the error message.
string formattedMessage_
Formatted message returned by what()
static int traceDepth_
Number of stack frames to show. 0 to disable.
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.
static void setStackTraceDepth(int depth)
Set the number of stack frames to include when a CanteraError is displayed.
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.