Skip to content

Commit

Permalink
Merge pull request #36501 from makortel/cutParserExceptionMessage
Browse files Browse the repository at this point in the history
Extend cutParser exception message temporarily to help debugging
  • Loading branch information
cmsbuild authored Dec 17, 2021
2 parents 4cd114c + 81f9403 commit 1081695
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
20 changes: 16 additions & 4 deletions CommonTools/Utils/src/MethodSetter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,22 @@ bool MethodSetter::push(const string& name, const vector<AnyMethodArgument>& arg
if (!bool(member)) {
// Not a data member either, fatal error, throw.
switch (error) {
case reco::parser::kNameDoesNotExist:
throw Exception(begin) << "no method or data member named \"" << name << "\" found for type \"" << type.name()
<< "\"";
break;
case reco::parser::kNameDoesNotExist: {
Exception ex(begin);
ex << "no method or data member named \"" << name << "\" found for type \"" << type.name() << "\"\n";
// The following information is for temporary debugging only, intended to be removed later
ex << "It has the following methods\n";
edm::TypeFunctionMembers functions(type);
for (auto const& f : functions) {
ex << " " << f->GetName() << "\n";
}
ex << "and the following data members\n";
edm::TypeDataMembers members(type);
for (auto const& m : members) {
ex << " " << m->GetName() << "\n";
}
throw ex;
} break;
case reco::parser::kIsNotPublic:
throw Exception(begin) << "data member named \"" << name << "\" for type \"" << type.name()
<< "\" is not publically accessible.";
Expand Down
3 changes: 2 additions & 1 deletion CommonTools/Utils/src/cutParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ bool reco::parser::cutParser(const edm::TypeWithDict& t, const std::string& cut,
returnValue = parse(startingFrom, grammar.use_parser<0>() >> end_p, space_p).full;
} catch (BaseException& e) {
throw edm::Exception(edm::errors::Configuration)
<< "Cut parser error:" << baseExceptionWhat(e) << " (char " << e.where - startingFrom << ")\n";
<< "Cut parser error:" << baseExceptionWhat(e) << " (char " << e.where - startingFrom << ")\n"
<< "Cut string was " << cut;
}
return returnValue;
}
Expand Down

0 comments on commit 1081695

Please sign in to comment.