ENH: use consistent naming when toggling exception throwing on/off

This commit is contained in:
Mark Olesen 2021-11-01 13:37:11 +01:00
parent fddf8a8832
commit 851be8ea33
26 changed files with 119 additions and 111 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -180,7 +180,7 @@ int main(int argc, char *argv[])
// Fatal with FULLDEBUG // Fatal with FULLDEBUG
{ {
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
const label nx = mesh.sizes().x(); const label nx = mesh.sizes().x();
const label ny = mesh.sizes().y(); const label ny = mesh.sizes().y();
@ -230,7 +230,7 @@ int main(int argc, char *argv[])
<< err.message().c_str() << nl; << err.message().c_str() << nl;
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -171,7 +172,7 @@ int main(int argc, char *argv[])
Info<< "\ntest operator[] non-const with out-of-range index\n"; Info<< "\ntest operator[] non-const with out-of-range index\n";
// Expect failure // Expect failure
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
try try
{ {
@ -190,7 +191,7 @@ int main(int argc, char *argv[])
Info<< "Failed (expected) " << err << nl << endl; Info<< "Failed (expected) " << err << nl << endl;
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
report(list1); report(list1);
} }
@ -198,7 +199,7 @@ int main(int argc, char *argv[])
Info<< "\ntest operator[] with out-of-range index\n"; Info<< "\ntest operator[] with out-of-range index\n";
// Expect failure // Expect failure
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
try try
{ {
@ -212,7 +213,7 @@ int main(int argc, char *argv[])
Info<< "Failed (expected) " << err << nl << endl; Info<< "Failed (expected) " << err << nl << endl;
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
report(list1); report(list1);
} }
@ -268,7 +269,7 @@ int main(int argc, char *argv[])
// Expect failure // Expect failure
{ {
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
Info<< "\ntest operator[] assignment with auto-vivify\n"; Info<< "\ntest operator[] assignment with auto-vivify\n";
@ -286,7 +287,7 @@ int main(int argc, char *argv[])
list1.set(36, list1.max_value); list1.set(36, list1.max_value);
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
report(list1); report(list1);
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -271,7 +271,7 @@ int main(int argc, char *argv[])
// This should fail (in FULLDEBUG) // This should fail (in FULLDEBUG)
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
try try
{ {
Info<<"Random position(10,5): " Info<<"Random position(10,5): "
@ -282,7 +282,7 @@ int main(int argc, char *argv[])
Info<< "Caught FatalError " << err << nl << endl; Info<< "Caught FatalError " << err << nl << endl;
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
Info<< "\nDone" << nl << endl; Info<< "\nDone" << nl << endl;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -40,7 +40,7 @@ void predicateTests_label(const word& optName, const argList& args)
{ {
Info<< "predicate tests for " << optName << nl; Info<< "predicate tests for " << optName << nl;
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
try try
{ {
label val; label val;
@ -52,7 +52,7 @@ void predicateTests_label(const word& optName, const argList& args)
<< err << nl << endl; << err << nl << endl;
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
} }
@ -60,7 +60,7 @@ void predicateTests_scalar(const word& optName, const argList& args)
{ {
Info<< "predicate tests for " << optName << nl; Info<< "predicate tests for " << optName << nl;
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
try try
{ {
scalar val; scalar val;
@ -72,7 +72,7 @@ void predicateTests_scalar(const word& optName, const argList& args)
<< err << nl << endl; << err << nl << endl;
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
} }

View File

@ -101,8 +101,8 @@ void doTest(const dictionary& dict)
Info<< dict.dictName() << dict << nl; Info<< dict.dictName() << dict << nl;
// Could fail? // Could fail?
const bool throwingIOError = FatalIOError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingIOErr = FatalIOError.throwing(true);
try try
{ {
@ -120,8 +120,8 @@ void doTest(const dictionary& dict)
{ {
Info<< "Caught FatalError " << err << nl << endl; Info<< "Caught FatalError " << err << nl << endl;
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
FatalIOError.throwExceptions(throwingIOError); FatalIOError.throwing(oldThrowingIOErr);
} }
@ -130,8 +130,8 @@ void doTest(const objectRegistry& obr, const dictionary& dict)
Info<< dict.dictName() << dict << nl; Info<< dict.dictName() << dict << nl;
// Could fail? // Could fail?
const bool throwingIOError = FatalIOError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingIOErr = FatalIOError.throwing(true);
try try
{ {
@ -148,8 +148,8 @@ void doTest(const objectRegistry& obr, const dictionary& dict)
{ {
Info<< "Caught FatalError " << err << nl << endl; Info<< "Caught FatalError " << err << nl << endl;
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
FatalIOError.throwExceptions(throwingIOError); FatalIOError.throwing(oldThrowingIOErr);
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -57,8 +57,8 @@ scalar try_readScalar(const dictionary& dict, const word& k)
{ {
scalar val(-GREAT); scalar val(-GREAT);
const bool throwingIOError = FatalIOError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingIOerr = FatalIOError.throwing(true);
try try
{ {
@ -75,8 +75,8 @@ scalar try_readScalar(const dictionary& dict, const word& k)
Info<< "readScalar(" << k << ") Caught FatalError " Info<< "readScalar(" << k << ") Caught FatalError "
<< err << nl << endl; << err << nl << endl;
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
FatalIOError.throwExceptions(throwingIOError); FatalIOError.throwing(oldThrowingIOerr);
return val; return val;
} }
@ -87,8 +87,8 @@ scalar try_getScalar(const dictionary& dict, const word& k)
{ {
scalar val(-GREAT); scalar val(-GREAT);
const bool throwingIOError = FatalIOError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingIOerr = FatalIOError.throwing(true);
try try
{ {
@ -105,8 +105,8 @@ scalar try_getScalar(const dictionary& dict, const word& k)
Info<< "get<scalar>(" << k << ") Caught FatalError " Info<< "get<scalar>(" << k << ") Caught FatalError "
<< err << nl << endl; << err << nl << endl;
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
FatalIOError.throwExceptions(throwingIOError); FatalIOError.throwing(oldThrowingIOerr);
return val; return val;
} }
@ -123,8 +123,8 @@ scalar try_getCheckScalar
{ {
scalar val(-GREAT); scalar val(-GREAT);
const bool throwingIOError = FatalIOError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingIOerr = FatalIOError.throwing(true);
try try
{ {
@ -141,8 +141,8 @@ scalar try_getCheckScalar
Info<< "getCheck<scalar>(" << k << ") Caught FatalError " Info<< "getCheck<scalar>(" << k << ") Caught FatalError "
<< err << nl << endl; << err << nl << endl;
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
FatalIOError.throwExceptions(throwingIOError); FatalIOError.throwing(oldThrowingIOerr);
return val; return val;
} }
@ -159,8 +159,8 @@ scalar try_getScalar(const entry* eptr, const word& k)
return val; return val;
} }
const bool throwingIOError = FatalIOError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingIOerr = FatalIOError.throwing(true);
try try
{ {
@ -177,8 +177,8 @@ scalar try_getScalar(const entry* eptr, const word& k)
Info<< "entry get<scalar>(" << k << ") Caught FatalError " Info<< "entry get<scalar>(" << k << ") Caught FatalError "
<< err << nl << endl; << err << nl << endl;
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
FatalIOError.throwExceptions(throwingIOError); FatalIOError.throwing(oldThrowingIOerr);
return val; return val;
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -94,7 +94,7 @@ unsigned checkDimensions
std::string errMsg; std::string errMsg;
// Expect some failures // Expect some failures
const bool prev = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
for for
( (
@ -127,7 +127,7 @@ unsigned checkDimensions
hadDimensionError(test, dimsOk, errMsg); hadDimensionError(test, dimsOk, errMsg);
} }
FatalError.throwExceptions(prev); FatalError.throwing(oldThrowingError);
return nFail; return nFail;
} }

View File

@ -56,8 +56,8 @@ int main(int argc, char *argv[])
if (!args.found("no-throw")) if (!args.found("no-throw"))
{ {
FatalIOError.throwExceptions(); FatalIOError.throwing(true);
FatalError.throwExceptions(); FatalError.throwing(true);
} }
try try

View File

@ -103,8 +103,8 @@ int main(int argc, char *argv[])
{ {
string str(t.stringToken()); string str(t.stringToken());
const bool throwingErr = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
const bool throwingIOErr = FatalIOError.throwExceptions(); const bool oldThrowingIOErr = FatalIOError.throwing(true);
try try
{ {
@ -128,8 +128,8 @@ int main(int argc, char *argv[])
Info<< err.message().c_str() << nl; Info<< err.message().c_str() << nl;
} }
FatalError.throwExceptions(throwingErr); FatalError.throwing(oldThrowingError);
FatalIOError.throwExceptions(throwingIOErr); FatalIOError.throwing(oldThrowingIOErr);
Info<< nl; Info<< nl;
} }
} }

View File

@ -148,7 +148,7 @@ int main(int argc, char *argv[])
#if 0 #if 0
// Expect failure, but triggers abort which cannot be caught // Expect failure, but triggers abort which cannot be caught
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
try try
{ {
labelledTri l1({1, 2, 3, 10, 24}); labelledTri l1({1, 2, 3, 10, 24});
@ -159,7 +159,7 @@ int main(int argc, char *argv[])
WarningInFunction WarningInFunction
<< "Caught FatalError " << err << nl << endl; << "Caught FatalError " << err << nl << endl;
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
#endif #endif
labelledTri l2({1, 2, 3}); labelledTri l2({1, 2, 3});

View File

@ -779,7 +779,7 @@ int main(int argc, char *argv[])
Info<< nl << "Expect a FatalError for findEtcFile() with a bad name:" Info<< nl << "Expect a FatalError for findEtcFile() with a bad name:"
<< nl; << nl;
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
try try
{ {
@ -792,7 +792,7 @@ int main(int argc, char *argv[])
Info<< nl << "findEtcFile() Caught FatalError " Info<< nl << "findEtcFile() Caught FatalError "
<< err << nl << endl; << err << nl << endl;
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
} }

View File

@ -144,8 +144,8 @@ unsigned testParsing
string errMsg; string errMsg;
// Expect some failures // Expect some failures
const bool prev1 = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
const bool prev2 = FatalIOError.throwExceptions(); const bool oldThrowingIOErr = FatalIOError.throwing(true);
for (const std::pair<bool, std::string>& test : tests) for (const std::pair<bool, std::string>& test : tests)
{ {
@ -169,8 +169,8 @@ unsigned testParsing
hadParsingError(test, result, errMsg); hadParsingError(test, result, errMsg);
} }
FatalError.throwExceptions(prev1); FatalError.throwing(oldThrowingError);
FatalIOError.throwExceptions(prev2); FatalIOError.throwing(oldThrowingIOErr);
return nFail; return nFail;
} }

View File

@ -110,7 +110,7 @@ void generalTests()
string me("Mark"); string me("Mark");
// Expect some failures: // Expect some failures:
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
try try
{ {
@ -214,7 +214,7 @@ void generalTests()
Info<< "Caught FatalError " << err << nl << endl; Info<< "Caught FatalError " << err << nl << endl;
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
} }
@ -224,7 +224,7 @@ void testExpressions(const UList<regexTest>& tests)
typename RegexType::results_type match; typename RegexType::results_type match;
// Expect some failures: // Expect some failures:
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
// Report matches: // Report matches:
for (const auto& testseq : tests) for (const auto& testseq : tests)
@ -282,7 +282,7 @@ void testExpressions(const UList<regexTest>& tests)
} }
} }
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -66,7 +66,7 @@ void testNumericEvaluation(const std::string& s)
<< s << nl << s << nl
<< "========" << nl; << "========" << nl;
const bool throwingIOError = FatalIOError.throwExceptions(); const bool oldThrowingIOErr = FatalIOError.throwing(true);
try try
{ {
@ -91,7 +91,7 @@ void testNumericEvaluation(const std::string& s)
Info<< "========" << nl << nl; Info<< "========" << nl << nl;
FatalIOError.throwExceptions(throwingIOError); FatalIOError.throwing(oldThrowingIOErr);
} }

View File

@ -813,8 +813,8 @@ int main(int argc, char *argv[])
// Whether to quit // Whether to quit
bool quit = false; bool quit = false;
FatalError.throwExceptions(); FatalError.throwing(true);
FatalIOError.throwExceptions(); FatalIOError.throwing(true);
do do
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2014 OpenFOAM Foundation Copyright (C) 2012-2014 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -63,7 +63,7 @@ int main(int argc, char *argv[])
word utilityName(argv[1]); word utilityName(argv[1]);
autoPtr<helpType> utility; autoPtr<helpType> utility;
const bool throwing = FatalError.throwExceptions(); const bool oldThrowingErr = FatalError.throwing(true);
try try
{ {
utility.reset(helpType::New(utilityName)); utility.reset(helpType::New(utilityName));
@ -76,7 +76,7 @@ int main(int argc, char *argv[])
<< err.message().c_str() << nl << err.message().c_str() << nl
<< exit(FatalError); << exit(FatalError);
} }
FatalError.throwExceptions(throwing); FatalError.throwing(oldThrowingErr);
utility().init(); utility().init();

View File

@ -105,8 +105,8 @@ void Foam::helpTypes::helpBoundary::fixedValueFieldConditions
// throw exceptions to avoid fatal errors when casting from generic patch // throw exceptions to avoid fatal errors when casting from generic patch
// type to incompatible patch type // type to incompatible patch type
FatalIOError.throwExceptions(); FatalIOError.throwing(true);
FatalError.throwExceptions(); FatalError.throwing(true);
bool foundFixed = false; bool foundFixed = false;
forAll(types, i) forAll(types, i)

View File

@ -67,7 +67,7 @@ PtrList<ensightFaMesh> ensightMeshesFa(regionNames.size());
{ {
autoPtr<faMesh> faMeshPtr; autoPtr<faMesh> faMeshPtr;
const bool throwing = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
try try
{ {
faMeshPtr.reset(new faMesh(mesh)); faMeshPtr.reset(new faMesh(mesh));
@ -76,7 +76,7 @@ PtrList<ensightFaMesh> ensightMeshesFa(regionNames.size());
{ {
faMeshPtr.reset(nullptr); faMeshPtr.reset(nullptr);
} }
FatalError.throwExceptions(throwing); FatalError.throwing(oldThrowingError);
if (faMeshPtr) if (faMeshPtr)
{ {

View File

@ -46,7 +46,7 @@ if (doFiniteArea)
if (nAreaFields) if (nAreaFields)
{ {
const bool throwing = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
try try
{ {
faMeshPtr.reset(new faMesh(meshProxy.baseMesh())); faMeshPtr.reset(new faMesh(meshProxy.baseMesh()));
@ -55,7 +55,7 @@ if (doFiniteArea)
{ {
faMeshPtr.clear(); faMeshPtr.clear();
} }
FatalError.throwExceptions(throwing); FatalError.throwing(oldThrowingError);
} }
if (faMeshPtr && nAreaFields) if (faMeshPtr && nAreaFields)

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -233,7 +233,7 @@ int main(int argc, char *argv[])
fields.updateSelection(); fields.updateSelection();
const bool throwingIOErr = FatalIOError.throwExceptions(); const bool oldThrowingIOErr = FatalIOError.throwing(true);
try try
{ {
@ -258,7 +258,7 @@ int main(int argc, char *argv[])
Info<< endl; Info<< endl;
// Restore previous exception throwing state // Restore previous exception throwing state
FatalIOError.throwExceptions(throwingIOErr); FatalIOError.throwing(oldThrowingIOErr);
} }
Info<< "End\n" << endl; Info<< "End\n" << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -137,7 +137,7 @@ Foam::IOobjectList::IOobjectList
); );
bool ok = false; bool ok = false;
const bool throwingIOerr = FatalIOError.throwExceptions(); const bool oldThrowingIOerr = FatalIOError.throwing(true);
try try
{ {
@ -149,7 +149,7 @@ Foam::IOobjectList::IOobjectList
Warning << err << nl << endl; Warning << err << nl << endl;
} }
FatalIOError.throwExceptions(throwingIOerr); FatalIOError.throwing(oldThrowingIOerr);
if (ok) if (ok)
{ {

View File

@ -159,12 +159,12 @@ public:
return throwing_; return throwing_;
} }
//- Specify exception throwing (default is activate) //- Specify exception throwing state (on or off)
// \return the previous throwing state // \return the previous throwing state
bool throwExceptions(bool doThrow = true) noexcept bool throwing(const bool on) noexcept
{ {
bool old = throwing_; bool old(throwing_);
throwing_ = doThrow; throwing_ = on;
return old; return old;
} }
@ -230,6 +230,13 @@ public:
// Housekeeping // Housekeeping
//- Specify exception throwing state (default is \b on)
// \return the previous throwing state
bool throwExceptions(const bool on = true) noexcept
{
return throwing(on);
}
//- Deactivate exception throwing //- Deactivate exception throwing
// \return the previous throwing state // \return the previous throwing state
bool dontThrowExceptions() noexcept bool dontThrowExceptions() noexcept

View File

@ -647,8 +647,8 @@ bool Foam::functionObjectList::execute()
{ {
// Throw FatalError, FatalIOError as exceptions // Throw FatalError, FatalIOError as exceptions
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
const bool throwingIOerr = FatalIOError.throwExceptions(); const bool oldThrowingIOerr = FatalIOError.throwing(true);
bool hadError = false; bool hadError = false;
@ -693,8 +693,8 @@ bool Foam::functionObjectList::execute()
if (hadError) if (hadError)
{ {
// Restore previous state // Restore previous state
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
FatalIOError.throwExceptions(throwingIOerr); FatalIOError.throwing(oldThrowingIOerr);
continue; continue;
} }
@ -736,8 +736,8 @@ bool Foam::functionObjectList::execute()
} }
// Restore previous state // Restore previous state
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
FatalIOError.throwExceptions(throwingIOerr); FatalIOError.throwing(oldThrowingIOerr);
} }
else else
{ {
@ -853,8 +853,8 @@ bool Foam::functionObjectList::end()
// Ignore failure on end() - not much we can do anyhow // Ignore failure on end() - not much we can do anyhow
// Throw FatalError, FatalIOError as exceptions // Throw FatalError, FatalIOError as exceptions
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
const bool throwingIOerr = FatalIOError.throwExceptions(); const bool oldThrowingIOerr = FatalIOError.throwing(true);
try try
{ {
@ -888,8 +888,8 @@ bool Foam::functionObjectList::end()
} }
// Restore previous state // Restore previous state
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
FatalIOError.throwExceptions(throwingIOerr); FatalIOError.throwing(oldThrowingIOerr);
} }
} }
@ -1083,8 +1083,8 @@ bool Foam::functionObjectList::read()
if (enabled && !objPtr) if (enabled && !objPtr)
{ {
// Throw FatalError, FatalIOError as exceptions // Throw FatalError, FatalIOError as exceptions
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
const bool throwingIOerr = FatalIOError.throwExceptions(); const bool oldThrowingIOerr = FatalIOError.throwing(true);
try try
{ {
@ -1148,8 +1148,8 @@ bool Foam::functionObjectList::read()
} }
// Restore previous state // Restore previous state
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
FatalIOError.throwExceptions(throwingIOerr); FatalIOError.throwing(oldThrowingIOerr);
// Require valid functionObject on all processors // Require valid functionObject on all processors
if (!returnReduce(bool(objPtr), andOp<bool>())) if (!returnReduce(bool(objPtr), andOp<bool>()))

View File

@ -140,7 +140,7 @@ if (argList::postProcess(argc, argv))
} }
} }
FatalIOError.throwExceptions(); FatalIOError.throwing(true);
try try
{ {

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -362,8 +362,8 @@ int main(int argc, char *argv[])
autoPtr<Time> runTimePtr; autoPtr<Time> runTimePtr;
autoPtr<lumpedPointIOMovement> movementPtr; autoPtr<lumpedPointIOMovement> movementPtr;
const bool throwingIOError = FatalIOError.throwExceptions(); const bool oldThrowingError = FatalError.throwing(true);
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingIOerr = FatalIOError.throwing(true);
try try
{ {
@ -380,8 +380,8 @@ int main(int argc, char *argv[])
} }
Info<< nl << endl; Info<< nl << endl;
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingError);
FatalIOError.throwExceptions(throwingIOError); FatalIOError.throwing(oldThrowingIOerr);
if (!movementPtr) if (!movementPtr)
{ {

View File

@ -408,8 +408,8 @@ int main(int argc, char *argv[])
autoPtr<Time> runTimePtr; autoPtr<Time> runTimePtr;
autoPtr<lumpedPointIOMovement> movementPtr; autoPtr<lumpedPointIOMovement> movementPtr;
const bool throwingIOError = FatalIOError.throwExceptions(); const bool oldThrowingIO = FatalIOError.throwing(true);
const bool throwingError = FatalError.throwExceptions(); const bool oldThrowingEx = FatalError.throwing(true);
try try
{ {
@ -426,8 +426,8 @@ int main(int argc, char *argv[])
} }
Info<< nl << endl; Info<< nl << endl;
FatalError.throwExceptions(throwingError); FatalError.throwing(oldThrowingEx);
FatalIOError.throwExceptions(throwingIOError); FatalIOError.throwing(oldThrowingIO);
if (!movementPtr) if (!movementPtr)
{ {