11 #ifndef CT_CTEXCEPTIONS_H 12 #define CT_CTEXCEPTIONS_H 78 template <
typename... Args>
84 if (
sizeof...(args) == 0) {
87 msg_ = fmt::format(msg, args...);
95 const char*
what()
const throw();
106 return "CanteraError";
152 return "ArraySizeError";
178 IndexError(
const std::string& func,
const std::string& arrayName,
size_t m,
size_t mmax) :
179 CanteraError(func), arrayName_(arrayName), m_(m), mmax_(mmax) {}
188 std::string arrayName_;
200 return "NotImplementedError";
205 #define XSTR_TRACE_LINE(s) STR_TRACE_LINE(s) 208 #define STR_TRACE_LINE(s) #s 214 #define STR_TRACE (std::string(__FILE__) + ":" + XSTR_TRACE_LINE(__LINE__)) 218 # define AssertTrace(expr) ((void) (0)) 221 # define AssertThrow(expr, procedure) ((void) (0)) 223 #ifndef AssertThrowMsg 224 # define AssertThrowMsg(expr,procedure, ...) ((void) (0)) 239 # define AssertTrace(expr) ((expr) ? (void) 0 : throw CanteraError(STR_TRACE, std::string("failed assert: ") + #expr)) 253 # define AssertThrow(expr, procedure) ((expr) ? (void) 0 : throw CanteraError(procedure, std::string("failed assert: ") + #expr)) 269 #ifndef AssertThrowMsg 270 # define AssertThrowMsg(expr, procedure, ...) ((expr) ? (void) 0 : throw CanteraError(procedure + std::string(":\nfailed assert: \"") + std::string(#expr) + std::string("\""), __VA_ARGS__)) 277 # define AssertFinite(expr, procedure, ...) AssertThrowMsg(expr < BigNumber && expr > -BigNumber, procedure, __VA_ARGS__) IndexError(const std::string &func, const std::string &arrayName, size_t m, size_t mmax)
Constructor.
Wrapper for either system-installed or local headers for fmt.
std::string formattedMessage_
Formatted message returned by what()
bool saved_
Exception has already been saved to Cantera's error stack.
An error indicating that an unimplemented function has been called.
std::string msg_
Message associated with the exception.
virtual std::string getMessage() const
Method overridden by derived classes to format the error message.
const char * what() const
Get a description of the error.
virtual std::string getMessage() const
Method overridden by derived classes to format the error message.
virtual std::string getMessage() const
Method overridden by derived classes to format the error message.
std::string procedure_
The name of the procedure where the exception occurred.
Base class for exceptions thrown by Cantera classes.
CanteraError()
Protected default constructor discourages throwing errors containing no information.
ArraySizeError(const std::string &procedure, size_t sz, size_t reqd)
Constructor.
CanteraError(const std::string &procedure, const std::string &msg, const Args &... args)
Normal Constructor for the CanteraError base class.
virtual std::string getClass() const
Method overridden by derived classes to indicate their type.
An array index is out of range.
Namespace for the Cantera kernel.
virtual std::string getClass() const
Method overridden by derived classes to indicate their type.
virtual std::string getClass() const
Method overridden by derived classes to indicate their type.
virtual std::string getClass() const
Method overridden by derived classes to indicate their type.
void save()
Function to put this error onto Cantera's error stack.
virtual ~CanteraError()
Destructor for base class does nothing.