AMPLException

class AMPLException : public runtime_error

Represent an exception generated by AMPL.

Subclassed by ampl::InvalidSubscriptException, ampl::SyntaxErrorException

Public Functions

AMPLException(const AMPLException &e)

Copy constructor.

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

Constructor.

Parameters
  • cause: Cause of the exception

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

~AMPLException()

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

const std::string &getSourceName() const

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

int getLineNumber() const

Get the row where the error is located.

int getOffset() const

Get the offset where the error is located.

const std::string &getMessage() const

Get the error message.

void setSourceName(const std::string &sourceName)

Overwrites the source name for this error.