Commit a18617bb authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: add line number for dictionary getCheck errors

parent 6ab69963
......@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -352,6 +352,7 @@ int main(int argc, char *argv[])
(
"good 3.14159;\n"
"negative -3.14159;\n"
"neg2 -3.14159;\n"
"empty;\n"
// "bad text;\n" // always fails
// "bad 3.14159 1234;\n" // fails for readScalar
......@@ -386,6 +387,7 @@ int main(int argc, char *argv[])
try_getCheckScalar(dict2, "good", scalarRange::gt0());
try_getCheckScalar(dict2, "negative", scalarRange::gt0());
try_getCheckScalar(dict2, "neg2", scalarRange::gt0());
try_getCheckScalar(dict2, "good", greaterOp1<scalar>(0));
try_getCheckScalar(dict2, "negative", greaterOp1<scalar>(0));
......
......@@ -338,7 +338,11 @@ void Foam::dictionary::checkITstream
}
void Foam::dictionary::raiseBadInput(const word& keyword) const
void Foam::dictionary::raiseBadInput
(
const ITstream& is,
const word& keyword
) const
{
// Can use FatalIOError instead of SafeFatalIOError
// since predicate checks are not used at the earliest stages
......@@ -347,10 +351,11 @@ void Foam::dictionary::raiseBadInput(const word& keyword) const
"", // functionName
"", // sourceFileName
0, // sourceFileLineNumber
*this // ios
this->name(), // ioFileName
is.lineNumber(), // ioStartLineNumber
-1 // ioEndLineNumber
)
<< "Entry '" << keyword << "' with invalid input in dictionary "
<< name() << nl << nl
<< "Entry '" << keyword << "' with invalid input" << nl
<< exit(FatalIOError);
}
......
......@@ -357,7 +357,7 @@ private:
//- Emit IOError about bad input for the entry
void raiseBadInput(const word& keyword) const;
void raiseBadInput(const ITstream& is, const word& keyword) const;
//- The case-relative dictionary name. Uses FOAM_CASE
fileName relativeName(const bool caseTag=false) const;
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -229,7 +229,7 @@ T Foam::dictionary::getCheckOrDefault
if (!pred(val))
{
raiseBadInput(keyword);
raiseBadInput(is, keyword);
}
return val;
......@@ -284,7 +284,7 @@ T Foam::dictionary::getCheckOrAdd
if (!pred(val))
{
raiseBadInput(keyword);
raiseBadInput(is, keyword);
}
return val;
......@@ -362,7 +362,7 @@ bool Foam::dictionary::readCheck
if (!pred(val))
{
raiseBadInput(keyword);
raiseBadInput(is, keyword);
}
return true;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment