Skip to content

Commit e12f662

Browse files
committed
Capturing error message with licensing problem
1 parent 7e20f77 commit e12f662

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

lib/coek/coek/solvers/gurobi/gurobi.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ void GurobiSolver::pre_solve()
189189
catch (GRBException e) {
190190
license_status = gurobi_license_status::error;
191191
results->termination_condition = TerminationCondition::license_problems;
192+
results->error_message = "Gurobi Error: Caught gurobi exception creating environment - " + e.getMessage();
192193
}
193194
if (available())
194195
gmodel = new GRBModel(*env);

lib/coek/test/coek_gurobi_test.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,11 @@ int main()
132132
auto m = test->model;
133133
assert(m.name() == "simplelp1");
134134
auto res = solver.solve(m);
135-
assert((res->termination_condition == coek::TerminationCondition::solver_not_available)
136-
or (res->termination_condition == coek::TerminationCondition::license_problems));
135+
auto ok = (res->termination_condition == coek::TerminationCondition::solver_not_available)
136+
or (res->termination_condition == coek::TerminationCondition::license_problems);
137+
std::cout << "Unexpected termination condition: " << coek::to_string(res->termination_condition) << std::endl;
138+
std::cout << "Error message: " << res->error_message << std::endl;
139+
assert(ok == true);
137140
}
138141
}
139142
}

lib/coek/test/solver/test_examples.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,10 @@ TEST_CASE("gurobi_examples", "[solvers][gurobi]")
332332
auto ok
333333
= (res->termination_condition == coek::TerminationCondition::solver_not_available)
334334
or (res->termination_condition == coek::TerminationCondition::license_problems);
335-
if (not ok)
335+
if (not ok) {
336336
std::cout << "Unexpected termination condition: " << coek::to_string(res->termination_condition) << std::endl;
337+
std::cout << "Error message: " << res->error_message << std::endl;
338+
}
337339
REQUIRE(ok == true);
338340
}
339341
// GCOVR_EXCL_STOP

lib/coek/test/solver/test_gurobi.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ TEST_CASE("gurobi_checks", "[solvers][gurobi]")
110110
auto ok
111111
= (res->termination_condition == coek::TerminationCondition::solver_not_available)
112112
or (res->termination_condition == coek::TerminationCondition::license_problems);
113-
if (not ok)
113+
if (not ok) {
114114
std::cout << "Unexpected termination condition: " << coek::to_string(res->termination_condition) << std::endl;
115+
std::cout << "Error message: " << res->error_message << std::endl;
116+
}
115117
REQUIRE(ok == true);
116118
}
117119
// GCOVR_EXCL_STOP

0 commit comments

Comments
 (0)