class ampl::AMPLException

Represent an exception generated by AMPL.

Public Functions

AMPLException(const AMPLException &e)

Copy constructor.


Default constructor.

AMPLException(fmt::CStringRef cause)


  • cause -

    Cause of the exception

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

Constructor for AMPL errors.

  • 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


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

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.

std::string getMessage() const

Get the error message.

void setSourceName(const std::string &sourceName)

Overwrites the source name for this error.