Program Listing for File exception.h

Return to documentation for file (include/amici/exception.h)

#ifndef amici_exception_h
#define amici_exception_h

#include "amici/defines.h" // necessary for realtype

#include <array>
#include <cstdarg>
#include <exception>

namespace amici {

class AmiException : public std::exception {
  public:
    AmiException(int const first_frame = 3);

    explicit AmiException(char const* fmt, ...);

    char const* what() const noexcept override;

    char const* getBacktrace() const;

    void storeBacktrace(int nMaxFrames, int const first_frame);

  protected:
    void storeMessage(char const* fmt, va_list argptr);

  private:
    std::array<char, 500> msg_;
    std::array<char, 500> trace_;
};

class CvodeException : public AmiException {
  public:
    CvodeException(
        int error_code, char const* function, char const* extra = nullptr
    );
};

class IDAException : public AmiException {
  public:
    IDAException(
        int error_code, char const* function, char const* extra = nullptr
    );
};

class IntegrationFailure : public AmiException {
  public:
    IntegrationFailure(int code, realtype t);

    int error_code;

    realtype time;
};

class IntegrationFailureB : public AmiException {
  public:
    IntegrationFailureB(int code, realtype t);

    int error_code;

    realtype time;
};

class SetupFailure : public AmiException {
  public:
    explicit SetupFailure(char const* fmt, ...);
};

class NewtonFailure : public AmiException {
  public:
    NewtonFailure(int code, char const* function);

    int error_code;
};

} // namespace amici

#endif /* amici_exception_h */