GRBException#

class GRBException : public std::runtime_error#

Gurobi exception object. Exceptions can be thrown by nearly every method in the Gurobi C++ API. GRBException inherits from std::runtime_error which allows you to catch Gurobi exceptions not only via:

catch (const GRBException& e) {
  cout << e.getMessage() << endl;
}

but also as standard C++ exceptions, such as:

catch (const std::runtime_error& e) {
  cout << e.what() << endl;
}

or:

catch (const std::exception& e) {
  cout << e.what() << endl;
}
GRBException GRBException(int errcode = 0)#

Exception constructor that creates a Gurobi exception with the given error code.

Parameters:

errcode – (optional) Error code for exception.

Returns:

An exception object.

GRBException GRBException(string errmsg, int errcode = 0)#

Exception constructor that creates a Gurobi exception with the given message string and error code.

Parameters:
  • errmsg – Error message for exception.

  • errcode – (optional) Error code for exception.

Returns:

An exception object.

int getErrorCode()#

Retrieve the error code associated with a Gurobi exception.

Returns:

The error code associated with the exception.

const string getMessage()#

Retrieve the error message associated with a Gurobi exception.

Returns:

The error message associated with the exception.