Skip to content

Commit a597663

Browse files
committed
[roc-config] Improve user feedback for invalid options
1 parent 877e493 commit a597663

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/CardConfigurator.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ void CardConfigurator::parseConfigUriCru(std::string configUri, Parameters& para
105105
try {
106106
conf = o2::configuration::ConfigurationFactory::getConfiguration(configUri);
107107
} catch (std::exception& e) {
108-
std::cout << boost::diagnostic_information(e) << std::endl;
109108
throw;
110109
}
111110

src/CommandLineUtilities/ProgramConfig.cxx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
using namespace AliceO2::roc::CommandLineUtilities;
2929
using namespace AliceO2::roc;
30-
using namespace AliceO2::InfoLogger;
3130
namespace po = boost::program_options;
3231

3332
class ProgramConfig : public Program
@@ -168,7 +167,7 @@ class ProgramConfig : public Program
168167
FirmwareChecker().checkFirmwareCompatibility(cardId);
169168
} catch (const Exception& e) {
170169
Logger::get() << boost::diagnostic_information(e) << LogErrorOps << endm;
171-
throw(e);
170+
throw;
172171
}
173172
}
174173

@@ -243,16 +242,16 @@ class ProgramConfig : public Program
243242
try {
244243
CardConfigurator(params, mOptions.forceConfig);
245244
} catch (const Exception& e) {
246-
Logger::get() << boost::diagnostic_information(e) << LogErrorOps << endm;
247-
throw(e);
245+
Logger::get() << e.what() << LogErrorOps << endm;
246+
throw;
248247
}
249248
} else {
250249
Logger::get() << "Configuring with config uri" << LogDebugOps << endm;
251250
try {
252251
CardConfigurator(cardId, mOptions.configUri, mOptions.forceConfig);
253-
} catch (std::runtime_error& e) {
254-
Logger::get() << "Error parsing the configuration..." << boost::diagnostic_information(e) << LogErrorOps << endm;
255-
throw(e);
252+
} catch (std::exception& e) {
253+
Logger::get() << e.what() << LogErrorOps << endm;
254+
throw;
256255
}
257256
}
258257
return;

src/Utilities/Enum.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ struct EnumConverter {
5252
return pair.first;
5353
}
5454
}
55-
BOOST_THROW_EXCEPTION(std::runtime_error("Failed to convert string to " + typeName + " enum"));
55+
56+
std::string errString = "Failed to convert string \"" + string + "\" to " + typeName + " enum\nPossible values:";
57+
for (const auto& el : mapping) {
58+
errString += " \"" + el.second + "\"";
59+
}
60+
61+
BOOST_THROW_EXCEPTION(std::runtime_error(errString));
5662
}
5763
};
5864

0 commit comments

Comments
 (0)