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 return "NotImplementedError";
200 #define XSTR_TRACE_LINE(s) STR_TRACE_LINE(s)
203 #define STR_TRACE_LINE(s) #s
209 #define STR_TRACE (std::string(__FILE__) + ":" + XSTR_TRACE_LINE(__LINE__))
213 # define AssertTrace(expr) ((void) (0))
216 # define AssertThrow(expr, procedure) ((void) (0))
218 #ifndef AssertThrowMsg
219 # define AssertThrowMsg(expr,procedure, ...) ((void) (0))
234 # define AssertTrace(expr) ((expr) ? (void) 0 : throw CanteraError(STR_TRACE, std::string("failed assert: ") + #expr))
248 # define AssertThrow(expr, procedure) ((expr) ? (void) 0 : throw CanteraError(procedure, std::string("failed assert: ") + #expr))
264 #ifndef AssertThrowMsg
265 # define AssertThrowMsg(expr, procedure, ...) ((expr) ? (void) 0 : throw CanteraError(procedure + std::string(":\nfailed assert: \"") + std::string(#expr) + std::string("\""), __VA_ARGS__))
272 # 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.
Wrapper for either system-installed or local headers for fmt.
Namespace for the Cantera kernel.