11#ifndef CT_CTEXCEPTIONS_H
12#define CT_CTEXCEPTIONS_H
77 template <
typename... Args>
82 if (
sizeof...(args) == 0) {
85 msg_ = fmt::format(msg, args...);
93 const char*
what()
const throw();
100 return "CanteraError";
145 return "ArraySizeError";
171 IndexError(
const std::string& func,
const std::string& arrayName,
size_t m,
size_t mmax) :
172 CanteraError(func), arrayName_(arrayName), m_(m), mmax_(mmax) {}
181 std::string arrayName_;
195 template <
typename... Args>
197 const Args&... args) :
201 return "NotImplementedError";
206#define XSTR_TRACE_LINE(s) STR_TRACE_LINE(s)
209#define STR_TRACE_LINE(s) #s
215#define STR_TRACE (std::string(__FILE__) + ":" + XSTR_TRACE_LINE(__LINE__))
219# define AssertTrace(expr) ((void) (0))
222# define AssertThrow(expr, procedure) ((void) (0))
224#ifndef AssertThrowMsg
225# define AssertThrowMsg(expr,procedure, ...) ((void) (0))
240# define AssertTrace(expr) ((expr) ? (void) 0 : throw CanteraError(STR_TRACE, std::string("failed assert: ") + #expr))
254# define AssertThrow(expr, procedure) ((expr) ? (void) 0 : throw CanteraError(procedure, std::string("failed assert: ") + #expr))
270#ifndef AssertThrowMsg
271# define AssertThrowMsg(expr, procedure, ...) ((expr) ? (void) 0 : throw CanteraError(procedure + std::string(":\nfailed assert: \"") + std::string(#expr) + std::string("\""), __VA_ARGS__))
278# define AssertFinite(expr, procedure, ...) AssertThrowMsg(expr < BigNumber && expr > -BigNumber, procedure, __VA_ARGS__)
virtual std::string getMessage() const
Method overridden by derived classes to format the error message.
virtual std::string getClass() const
Method overridden by derived classes to indicate their type.
ArraySizeError(const std::string &procedure, size_t sz, size_t reqd)
Constructor.
Base class for exceptions thrown by Cantera classes.
virtual std::string getMessage() const
Method overridden by derived classes to format the error message.
std::string msg_
Message associated with the exception.
virtual std::string getClass() const
Method overridden by derived classes to indicate their type.
std::string procedure_
The name of the procedure where the exception occurred.
const char * what() const
Get a description of the error.
std::string formattedMessage_
Formatted message returned by what()
CanteraError(const std::string &procedure, const std::string &msg, const Args &... args)
Normal Constructor for the CanteraError base class.
virtual ~CanteraError()
Destructor for base class does nothing.
CanteraError()
Protected default constructor discourages throwing errors containing no information.
An array index is out of range.
virtual std::string getMessage() const
Method overridden by derived classes to format the error message.
virtual std::string getClass() const
Method overridden by derived classes to indicate their type.
IndexError(const std::string &func, const std::string &arrayName, size_t m, size_t mmax)
Constructor.
An error indicating that an unimplemented function has been called.
NotImplementedError(const std::string &func)
virtual std::string getClass() const
Method overridden by derived classes to indicate their type.
NotImplementedError(const std::string &func, const std::string &msg, const Args &... args)
Alternative constructor taking same arguments as.
Wrapper for either system-installed or local headers for fmt.
Namespace for the Cantera kernel.