mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: make dictionary error more descriptive (#1065)
This commit is contained in:
@ -248,7 +248,7 @@ void Foam::dictionary::checkITstream
|
|||||||
is.lineNumber() // ioStartLineNumber
|
is.lineNumber() // ioStartLineNumber
|
||||||
);
|
);
|
||||||
|
|
||||||
err << "'" << keyword << "' has "
|
err << "Entry '" << keyword << "' has "
|
||||||
<< remaining << " excess tokens in stream" << nl << nl
|
<< remaining << " excess tokens in stream" << nl << nl
|
||||||
<< " ";
|
<< " ";
|
||||||
is.writeList(err, 0);
|
is.writeList(err, 0);
|
||||||
@ -262,7 +262,7 @@ void Foam::dictionary::checkITstream
|
|||||||
<< "--> FOAM FATAL IO ERROR:" << nl;
|
<< "--> FOAM FATAL IO ERROR:" << nl;
|
||||||
|
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "'" << keyword << "' has "
|
<< "Entry '" << keyword << "' has "
|
||||||
<< remaining << " excess tokens in stream" << nl << nl;
|
<< remaining << " excess tokens in stream" << nl << nl;
|
||||||
|
|
||||||
std::cerr
|
std::cerr
|
||||||
@ -286,7 +286,8 @@ void Foam::dictionary::checkITstream
|
|||||||
this->name(), // ioFileName
|
this->name(), // ioFileName
|
||||||
is.lineNumber() // ioStartLineNumber
|
is.lineNumber() // ioStartLineNumber
|
||||||
)
|
)
|
||||||
<< "'" << keyword << "' had no tokens in stream" << nl << nl
|
<< "Entry '" << keyword
|
||||||
|
<< "' had no tokens in stream" << nl << nl
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -294,7 +295,8 @@ void Foam::dictionary::checkITstream
|
|||||||
std::cerr
|
std::cerr
|
||||||
<< nl
|
<< nl
|
||||||
<< "--> FOAM FATAL IO ERROR:" << nl
|
<< "--> FOAM FATAL IO ERROR:" << nl
|
||||||
<< "'" << keyword << "' had no tokens in stream" << nl << nl;
|
<< "Entry '" << keyword
|
||||||
|
<< "' had no tokens in stream" << nl << nl;
|
||||||
|
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "file: " << this->name()
|
<< "file: " << this->name()
|
||||||
@ -358,7 +360,7 @@ const Foam::entry& Foam::dictionary::lookupEntry
|
|||||||
if (!finder.found())
|
if (!finder.found())
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "'" << keyword << "' not found in dictionary "
|
<< "Entry '" << keyword << "' not found in dictionary "
|
||||||
<< name()
|
<< name()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
@ -472,7 +474,7 @@ const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
|
|||||||
if (!finder.found())
|
if (!finder.found())
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "'" << keyword << "' not found in dictionary "
|
<< "Entry '" << keyword << "' not found in dictionary "
|
||||||
<< name()
|
<< name()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
@ -489,7 +491,7 @@ Foam::dictionary& Foam::dictionary::subDict(const word& keyword)
|
|||||||
if (!finder.found())
|
if (!finder.found())
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "'" << keyword << "' not found in dictionary "
|
<< "Entry '" << keyword << "' not found in dictionary "
|
||||||
<< name()
|
<< name()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
@ -516,7 +518,7 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict
|
|||||||
if (mandatory)
|
if (mandatory)
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "'" << keyword
|
<< "Entry '" << keyword
|
||||||
<< "' is not a sub-dictionary in dictionary "
|
<< "' is not a sub-dictionary in dictionary "
|
||||||
<< name()
|
<< name()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
@ -525,7 +527,7 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict
|
|||||||
if (finder.found())
|
if (finder.found())
|
||||||
{
|
{
|
||||||
IOWarningInFunction(*this)
|
IOWarningInFunction(*this)
|
||||||
<< "'" << keyword
|
<< "Entry '" << keyword
|
||||||
<< "' found but not a sub-dictionary in dictionary "
|
<< "' found but not a sub-dictionary in dictionary "
|
||||||
<< name() << endl;
|
<< name() << endl;
|
||||||
}
|
}
|
||||||
@ -551,7 +553,7 @@ const Foam::dictionary& Foam::dictionary::optionalSubDict
|
|||||||
if (finder.found())
|
if (finder.found())
|
||||||
{
|
{
|
||||||
IOWarningInFunction(*this)
|
IOWarningInFunction(*this)
|
||||||
<< "'" << keyword
|
<< "Entry '" << keyword
|
||||||
<< "' found but not a sub-dictionary in dictionary "
|
<< "' found but not a sub-dictionary in dictionary "
|
||||||
<< name() << endl;
|
<< name() << endl;
|
||||||
}
|
}
|
||||||
@ -639,7 +641,7 @@ Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
|
|||||||
|
|
||||||
|
|
||||||
IOWarningInFunction(*this)
|
IOWarningInFunction(*this)
|
||||||
<< "problem replacing entry "<< entryPtr->keyword()
|
<< "Problem replacing entry "<< entryPtr->keyword()
|
||||||
<< " in dictionary " << name() << endl;
|
<< " in dictionary " << name() << endl;
|
||||||
|
|
||||||
parent_type::remove(entryPtr);
|
parent_type::remove(entryPtr);
|
||||||
@ -665,9 +667,8 @@ Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
|
|||||||
|
|
||||||
|
|
||||||
IOWarningInFunction(*this)
|
IOWarningInFunction(*this)
|
||||||
<< "attempt to add entry " << entryPtr->keyword()
|
<< "Attempt to add entry " << entryPtr->keyword()
|
||||||
<< " which already exists in dictionary " << name()
|
<< " which already exists in dictionary " << name() << endl;
|
||||||
<< endl;
|
|
||||||
|
|
||||||
delete entryPtr;
|
delete entryPtr;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -772,7 +773,8 @@ bool Foam::dictionary::merge(const dictionary& dict)
|
|||||||
if (this == &dict)
|
if (this == &dict)
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "attempted merge to self for dictionary " << name()
|
<< "Attempted merge to self for dictionary "
|
||||||
|
<< name()
|
||||||
<< abort(FatalIOError);
|
<< abort(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -840,7 +842,8 @@ void Foam::dictionary::operator=(const dictionary& rhs)
|
|||||||
if (this == &rhs)
|
if (this == &rhs)
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "attempted assignment to self for dictionary " << name()
|
<< "Attempted assignment to self for dictionary "
|
||||||
|
<< name()
|
||||||
<< abort(FatalIOError);
|
<< abort(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -77,7 +77,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchCompat
|
|||||||
std::cerr
|
std::cerr
|
||||||
<< "--> FOAM IOWarning :" << nl
|
<< "--> FOAM IOWarning :" << nl
|
||||||
<< " Found [v" << iter.second << "] '"
|
<< " Found [v" << iter.second << "] '"
|
||||||
<< iter.first << "' instead of '"
|
<< iter.first << "' entry instead of '"
|
||||||
<< keyword.c_str() << "' in dictionary \""
|
<< keyword.c_str() << "' in dictionary \""
|
||||||
<< name().c_str() << "\" "
|
<< name().c_str() << "\" "
|
||||||
<< nl
|
<< nl
|
||||||
@ -128,7 +128,7 @@ const Foam::entry& Foam::dictionary::lookupEntryCompat
|
|||||||
if (!finder.found())
|
if (!finder.found())
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "'" << keyword << "' not found in dictionary "
|
<< "Entry '" << keyword << "' not found in dictionary "
|
||||||
<< name()
|
<< name()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,7 +89,7 @@ bool Foam::dictionary::read(Istream& is, bool keepHeader)
|
|||||||
if (!is.good())
|
if (!is.good())
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(is)
|
FatalIOErrorInFunction(is)
|
||||||
<< "Istream not OK for reading dictionary "
|
<< "Istream not OK for reading dictionary " << name()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -102,7 +102,7 @@ bool Foam::dictionary::read(Istream& is, bool keepHeader)
|
|||||||
if (currToken == token::END_BLOCK)
|
if (currToken == token::END_BLOCK)
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(is)
|
FatalIOErrorInFunction(is)
|
||||||
<< "Dictionary input cannot start with '}'"
|
<< "Dictionary input cannot start with '}'" << nl
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
else if (currToken != token::BEGIN_BLOCK)
|
else if (currToken != token::BEGIN_BLOCK)
|
||||||
@ -185,7 +185,7 @@ void Foam::dictionary::writeEntries(Ostream& os, const bool extraNewLine) const
|
|||||||
if (!os.good())
|
if (!os.good())
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "Can't write entry " << e.keyword()
|
<< "Cannot write entry " << e.keyword()
|
||||||
<< " for dictionary " << name()
|
<< " for dictionary " << name()
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -629,9 +629,8 @@ bool Foam::dictionary::changeKeyword
|
|||||||
if (iter()->keyword().isPattern())
|
if (iter()->keyword().isPattern())
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "Old keyword "<< oldKeyword
|
<< "Old keyword " << oldKeyword << " is a pattern." << nl
|
||||||
<< " is a pattern."
|
<< "Pattern replacement is not supported." << nl
|
||||||
<< "Pattern replacement not yet implemented."
|
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -664,7 +663,7 @@ bool Foam::dictionary::changeKeyword
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
IOWarningInFunction(*this)
|
IOWarningInFunction(*this)
|
||||||
<< "cannot rename keyword "<< oldKeyword
|
<< "Cannot rename keyword " << oldKeyword
|
||||||
<< " to existing keyword " << newKeyword
|
<< " to existing keyword " << newKeyword
|
||||||
<< " in dictionary " << name() << endl;
|
<< " in dictionary " << name() << endl;
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -100,7 +100,8 @@ bool Foam::dictionary::readCompat
|
|||||||
else if (mandatory)
|
else if (mandatory)
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "Entry '" << keyword << "' not found in dictionary " << name()
|
<< "Entry '" << keyword << "' not found in dictionary "
|
||||||
|
<< name()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +199,8 @@ bool Foam::dictionary::readEntry
|
|||||||
else if (mandatory)
|
else if (mandatory)
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "Entry '" << keyword << "' not found in dictionary " << name()
|
<< "Entry '" << keyword << "' not found in dictionary "
|
||||||
|
<< name()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -92,7 +92,7 @@ void Foam::entry::checkITstream(const ITstream& is) const
|
|||||||
is.lineNumber() // ioStartLineNumber
|
is.lineNumber() // ioStartLineNumber
|
||||||
);
|
);
|
||||||
|
|
||||||
err << "'" << keyword << "' has "
|
err << "Entry '" << keyword << "' has "
|
||||||
<< remaining << " excess tokens in stream" << nl << nl
|
<< remaining << " excess tokens in stream" << nl << nl
|
||||||
<< " ";
|
<< " ";
|
||||||
is.writeList(err, 0);
|
is.writeList(err, 0);
|
||||||
@ -106,7 +106,7 @@ void Foam::entry::checkITstream(const ITstream& is) const
|
|||||||
<< "--> FOAM FATAL IO ERROR:" << nl;
|
<< "--> FOAM FATAL IO ERROR:" << nl;
|
||||||
|
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "'" << keyword << "' has "
|
<< "Entry '" << keyword << "' has "
|
||||||
<< remaining << " excess tokens in stream" << nl << nl;
|
<< remaining << " excess tokens in stream" << nl << nl;
|
||||||
|
|
||||||
std::cerr
|
std::cerr
|
||||||
@ -130,7 +130,8 @@ void Foam::entry::checkITstream(const ITstream& is) const
|
|||||||
this->name(), // ioFileName
|
this->name(), // ioFileName
|
||||||
is.lineNumber() // ioStartLineNumber
|
is.lineNumber() // ioStartLineNumber
|
||||||
)
|
)
|
||||||
<< "'" << keyword << "' had no tokens in stream" << nl << nl
|
<< "Entry '" << keyword
|
||||||
|
<< "' had no tokens in stream" << nl << nl
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -138,7 +139,8 @@ void Foam::entry::checkITstream(const ITstream& is) const
|
|||||||
std::cerr
|
std::cerr
|
||||||
<< nl
|
<< nl
|
||||||
<< "--> FOAM FATAL IO ERROR:" << nl
|
<< "--> FOAM FATAL IO ERROR:" << nl
|
||||||
<< "'" << keyword << "' had no tokens in stream" << nl << nl;
|
<< "Entry '" << keyword
|
||||||
|
<< "' had no tokens in stream" << nl << nl;
|
||||||
|
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "file: " << this->name()
|
<< "file: " << this->name()
|
||||||
|
|||||||
@ -213,7 +213,7 @@ void Foam::argList::checkITstream(const ITstream& is, const label index)
|
|||||||
std::cerr
|
std::cerr
|
||||||
<< nl
|
<< nl
|
||||||
<< "--> FOAM WARNING:" << nl
|
<< "--> FOAM WARNING:" << nl
|
||||||
<< "argument " << index << " has "
|
<< "Argument " << index << " has "
|
||||||
<< remaining << " excess tokens" << nl << nl;
|
<< remaining << " excess tokens" << nl << nl;
|
||||||
}
|
}
|
||||||
else if (!is.size())
|
else if (!is.size())
|
||||||
@ -221,7 +221,7 @@ void Foam::argList::checkITstream(const ITstream& is, const label index)
|
|||||||
std::cerr
|
std::cerr
|
||||||
<< nl
|
<< nl
|
||||||
<< "--> FOAM WARNING:" << nl
|
<< "--> FOAM WARNING:" << nl
|
||||||
<< "argument " << index << " had no tokens" << nl << nl;
|
<< "Argument " << index << " had no tokens" << nl << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ void Foam::argList::checkITstream(const ITstream& is, const word& optName)
|
|||||||
std::cerr
|
std::cerr
|
||||||
<< nl
|
<< nl
|
||||||
<< "--> FOAM WARNING:" << nl
|
<< "--> FOAM WARNING:" << nl
|
||||||
<< "option -" << optName << " has "
|
<< "Option -" << optName << " has "
|
||||||
<< remaining << " excess tokens" << nl << nl;
|
<< remaining << " excess tokens" << nl << nl;
|
||||||
}
|
}
|
||||||
else if (!is.size())
|
else if (!is.size())
|
||||||
@ -243,7 +243,7 @@ void Foam::argList::checkITstream(const ITstream& is, const word& optName)
|
|||||||
std::cerr
|
std::cerr
|
||||||
<< nl
|
<< nl
|
||||||
<< "--> FOAM WARNING:" << nl
|
<< "--> FOAM WARNING:" << nl
|
||||||
<< "option -" << optName << " had no tokens" << nl << nl;
|
<< "Option -" << optName << " had no tokens" << nl << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user