Skip to content

Commit 13bdce1

Browse files
f3schshahor02
authored andcommitted
HBFUtils: Optional throw on failed parsing of opt
This also fixed the use of ’--hbfutils-config none’.
1 parent 19fd697 commit 13bdce1

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

Detectors/Raw/include/DetectorsRaw/HBFUtilsInitializer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct HBFUtilsInitializer {
6464
static o2::dataformats::IRFrame IRFrameSel; // IRFrame selected for the current TF
6565

6666
HBFUtilsInitializer(const o2::framework::ConfigContext& configcontext, o2::framework::WorkflowSpec& wf);
67-
static HBFOpt getOptType(const std::string& optString);
67+
static HBFOpt getOptType(const std::string& optString, bool throwOnFailure = true);
6868
static std::vector<o2::dataformats::TFIDInfo> readTFIDInfoVector(const std::string& fname);
6969
static void readIRFramesVector(const std::string& fname);
7070
static void assignDataHeaderFromTFIDInfo(const std::vector<o2::dataformats::TFIDInfo>& tfinfoVec, o2::header::DataHeader& dh, o2::framework::DataProcessingHeader& dph);

Detectors/Raw/src/HBFUtilsInitializer.cxx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ HBFUtilsInitializer::HBFUtilsInitializer(const o2f::ConfigContext& configcontext
6565
upstream = true;
6666
continue;
6767
}
68-
HBFOpt opt = getOptType(optStr);
68+
HBFOpt opt = getOptType(optStr, !helpasked); // do not throw on unknown opt if help-opt was given
6969
nopts++;
7070
if ((opt == HBFOpt::INI || opt == HBFOpt::JSON) && !helpasked) {
7171
o2::conf::ConfigurableParam::updateFromFile(optStr, "HBFUtils", true); // update only those values which were not touched yet (provenance == kCODE)
@@ -78,8 +78,6 @@ HBFUtilsInitializer::HBFUtilsInitializer(const o2f::ConfigContext& configcontext
7878
hbfuInput = optStr;
7979
} else if (opt == HBFOpt::ROOT) {
8080
rootFileInput = optStr;
81-
} else if (!helpasked) {
82-
LOGP(fatal, "uknown hbfutils-config option {}", optStr);
8381
}
8482
}
8583
if (!nopts && !helpasked) {
@@ -125,7 +123,7 @@ HBFUtilsInitializer::HBFUtilsInitializer(const o2f::ConfigContext& configcontext
125123
}
126124

127125
//_________________________________________________________
128-
HBFUtilsInitializer::HBFOpt HBFUtilsInitializer::getOptType(const std::string& optString)
126+
HBFUtilsInitializer::HBFOpt HBFUtilsInitializer::getOptType(const std::string& optString, bool throwOnFailure)
129127
{
130128
// return type of the file provided via HBFConfOpt
131129
HBFOpt opt = HBFOpt::NONE;
@@ -138,7 +136,7 @@ HBFUtilsInitializer::HBFOpt HBFUtilsInitializer::getOptType(const std::string& o
138136
opt = HBFOpt::ROOT;
139137
} else if (optString == HBFUSrc) {
140138
opt = HBFOpt::HBFUTILS;
141-
} else if (optString != "none") {
139+
} else if (optString != "none" && throwOnFailure) {
142140
throw std::runtime_error(fmt::format("invalid option {} for {}", optString, HBFConfOpt));
143141
}
144142
}

0 commit comments

Comments
 (0)