AMPLException

class ampl::AMPLException : public std::runtime_error

Represent an exception generated by AMPL.

Subclassed by ampl::InvalidSubscriptException, ampl::SyntaxErrorException

Public Functions

inline AMPLException(const AMPLException &e)

Copy constructor.

inline explicit AMPLException(fmt::CStringRef cause = fmt::CStringRef(""))

Constructor.

Parameters

cause – Cause of the exception

inline AMPLException(fmt::CStringRef filename, int row, int offset, fmt::CStringRef message)

Constructor for AMPL errors.

Parameters
  • filename – Name of the file in which the exception occurred

  • row – Row where the error is detected

  • offset – Offset where the error is detected

  • message – Message to be embedded in the exception

inline ~AMPLException()

Here to avoid the error looser throw specifier for virtual AMPLException::~AMPLException() in some old c++ compilers.

inline const std::string &getSourceName() const

Get the name of the file where the error was detected.

inline int getLineNumber() const

Get the row where the error is located.

inline int getOffset() const

Get the offset where the error is located.

inline const std::string &getMessage() const

Get the error message.

inline void setSourceName(const std::string &sourceName)

Overwrites the source name for this error.