From b15a483b2bcf8f12dfb58301901747b588f59bb6 Mon Sep 17 00:00:00 2001 From: Christian Valente Date: Wed, 31 May 2023 00:33:23 +0200 Subject: [PATCH] Removed unused variables and added error messages to AMPLS?etOption functions. --- src/solver.cc | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/solver.cc b/src/solver.cc index 812ca3dc8..eedc146a9 100644 --- a/src/solver.cc +++ b/src/solver.cc @@ -1255,34 +1255,44 @@ AMPLS_C_Option* AMPLSGetOptions(AMPLS_MP_Solver* slv) { template int AMPLSetOption(AMPLS_MP_Solver* slv, const char* name, T v) { auto be = AMPLSGetBackend(slv); - auto ii = ((AMPLS_MP__internal*)(slv->internal_info_)); try { auto opt = be->GetOption(name); opt->SetValue(v); return 0; } - catch (const mp::OptionError& ) { + catch (const mp::OptionError& o) { + ((AMPLS_MP__internal*)(slv->internal_info_))->msg_extra_. + push_back(o.what()); return 1; } + catch (const std::runtime_error& e) { + ((AMPLS_MP__internal*)(slv->internal_info_))->msg_extra_. + push_back(e.what()); + } catch (const std::exception& ) { - return 2; } + return 2; } template int AMPLSGetOption(AMPLS_MP_Solver* slv, const char* name, T v) { auto be = AMPLSGetBackend(slv); - auto ii = ((AMPLS_MP__internal*)(slv->internal_info_)); try { auto opt = be->GetOption(name); opt->GetValue(*v); return 0; } - catch (const mp::OptionError& ) { + catch (const mp::OptionError& o) { + ((AMPLS_MP__internal*)(slv->internal_info_))->msg_extra_. + push_back(o.what()); return 1; } - catch (const std::exception& ) { - return 2; + catch (const std::runtime_error& e) { + ((AMPLS_MP__internal*)(slv->internal_info_))->msg_extra_. + push_back(e.what()); + } + catch (const std::exception&) { } + return 2; } int AMPLSSetIntOption(AMPLS_MP_Solver* slv, const char* name, int v) { @@ -1320,5 +1330,4 @@ int AMPLSGetStrOption(AMPLS_MP_Solver* slv, catch (const std::exception&) { return 2; } - //TODO }