How to access CPLEX.CplexError in JuMP 0.18?

#1

Dear community,
I always start cplex like for instance:

try
    status = solve(model)
    println("status: ", status)
    println("obj_val: ", getobjectivevalue(model))
catch msg
    println("ERROR SOLVING MODEL: ", msg)
end

In my case typeof(msg) returns CPLEX.CplexError if solve(model) is catched, and from the example above I obtain

ERROR SOLVING MODEL: CPLEX.CplexError(1001, "CPLEX Error  1001: Out of memory.\n")

How can I obtain which error cplex throwed? Basically I am searching for somthing like

if CPLEX.CplexError(??) == 1001
   #do something
end

I also tried in the example above to convert the message to a string, i.e., string(msg), but this did work out either (and it does not seem to be a good solution to me).

Thank you in advance, mike

#2

Here is the definition of CplexError.

I guess you want

if msg.code == 1001
    # do something
end
1 Like
#3

Thank you so much - this is exactly what I needed :slight_smile: