ENH: report best dictionary context for failed foamDictionary search (#3379)

This commit is contained in:
Mark Olesen
2025-06-19 17:40:30 +02:00
committed by Kutalmis Bercin
parent 615aae61d7
commit bbef1bc289

View File

@ -251,18 +251,31 @@ const dictionary& lookupScopedDict
return dict;
}
const entry* eptr = dict.findScoped(subDictName, keyType::LITERAL);
const auto finder = dict.csearchScoped(subDictName, keyType::LITERAL);
if (!eptr || !eptr->isDict())
if (!finder.good() || !finder.isDict())
{
// Not found or not a dictionary
FatalIOErrorInFunction(dict)
<< "'" << subDictName << "' not found in dictionary "
<< dict.name() << " or is not a dictionary" << nl
<< "Known entries are " << dict.keys()
<< '"' << subDictName << '"' << nl;
if (!finder.good())
{
FatalIOError << "Not found in dictionary";
}
else
{
FatalIOError << "Not a dictionary entry";
}
FatalIOError
<< nl << nl
<< "Known entries of " << finder.context().name() << " : " << nl
<< finder.context().keys()
<< exit(FatalIOError);
}
return eptr->dict();
return finder.dict();
}