From 851be8ea33cb17085d99b7cad2cf1a9475aa23a0 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 1 Nov 2021 13:37:11 +0100 Subject: [PATCH] ENH: use consistent naming when toggling exception throwing on/off --- .../test/PDRblockMesh/Test-PDRblockMesh.C | 6 ++-- .../test/PackedList1/Test-PackedList1.C | 13 +++---- applications/test/Random/Test-Random.C | 6 ++-- applications/test/argList/Test-argList.C | 10 +++--- .../coordinateSystem/Test-coordinateSystem.C | 16 ++++----- .../test/dictionary2/Test-dictionary2.C | 34 +++++++++---------- .../test/dimensionSet/Test-dimensionSet.C | 6 ++-- applications/test/error/Test-error.C | 4 +-- applications/test/exprEntry/Test-exprEntry.C | 8 ++--- applications/test/faces/Test-faces.C | 4 +-- applications/test/fileName/Test-fileName.C | 4 +-- .../test/primitives/Test-primitives.C | 8 ++--- applications/test/regex1/Test-regex1.C | 8 ++--- applications/test/string2/Test-string2.C | 6 ++-- .../mesh/manipulation/setSet/setSet.C | 4 +-- .../miscellaneous/foamHelp/foamHelp.C | 6 ++-- .../helpBoundary/helpBoundaryTemplates.C | 4 +-- .../foamToEnsight/createMeshAccounting.H | 4 +-- .../foamToVTK/convertAreaFields.H | 4 +-- .../postProcessing/postProcess/postProcess.C | 6 ++-- src/OpenFOAM/db/IOobjectList/IOobjectList.C | 6 ++-- src/OpenFOAM/db/error/error.H | 15 +++++--- .../functionObjectList/functionObjectList.C | 28 +++++++-------- .../functionObjectList/postProcess.H | 2 +- .../bridge/code/polynomial-motion.C | 10 +++--- .../building/code/building-motion.C | 8 ++--- 26 files changed, 119 insertions(+), 111 deletions(-) diff --git a/applications/test/PDRblockMesh/Test-PDRblockMesh.C b/applications/test/PDRblockMesh/Test-PDRblockMesh.C index cbbf7031253..02b0ccbf6a9 100644 --- a/applications/test/PDRblockMesh/Test-PDRblockMesh.C +++ b/applications/test/PDRblockMesh/Test-PDRblockMesh.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -180,7 +180,7 @@ int main(int argc, char *argv[]) // Fatal with FULLDEBUG { - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); const label nx = mesh.sizes().x(); const label ny = mesh.sizes().y(); @@ -230,7 +230,7 @@ int main(int argc, char *argv[]) << err.message().c_str() << nl; } - FatalError.throwExceptions(throwingError); + FatalError.throwing(oldThrowingError); } diff --git a/applications/test/PackedList1/Test-PackedList1.C b/applications/test/PackedList1/Test-PackedList1.C index 7d3f92adf19..812a82b8115 100644 --- a/applications/test/PackedList1/Test-PackedList1.C +++ b/applications/test/PackedList1/Test-PackedList1.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License 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"; // Expect failure - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); try { @@ -190,7 +191,7 @@ int main(int argc, char *argv[]) Info<< "Failed (expected) " << err << nl << endl; } - FatalError.throwExceptions(throwingError); + FatalError.throwing(oldThrowingError); report(list1); } @@ -198,7 +199,7 @@ int main(int argc, char *argv[]) Info<< "\ntest operator[] with out-of-range index\n"; // Expect failure - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); try { @@ -212,7 +213,7 @@ int main(int argc, char *argv[]) Info<< "Failed (expected) " << err << nl << endl; } - FatalError.throwExceptions(throwingError); + FatalError.throwing(oldThrowingError); report(list1); } @@ -268,7 +269,7 @@ int main(int argc, char *argv[]) // Expect failure { - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); Info<< "\ntest operator[] assignment with auto-vivify\n"; @@ -286,7 +287,7 @@ int main(int argc, char *argv[]) list1.set(36, list1.max_value); } - FatalError.throwExceptions(throwingError); + FatalError.throwing(oldThrowingError); report(list1); } diff --git a/applications/test/Random/Test-Random.C b/applications/test/Random/Test-Random.C index 75b286755cf..7ff308cf8a8 100644 --- a/applications/test/Random/Test-Random.C +++ b/applications/test/Random/Test-Random.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -271,7 +271,7 @@ int main(int argc, char *argv[]) // This should fail (in FULLDEBUG) - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); try { Info<<"Random position(10,5): " @@ -282,7 +282,7 @@ int main(int argc, char *argv[]) Info<< "Caught FatalError " << err << nl << endl; } - FatalError.throwExceptions(throwingError); + FatalError.throwing(oldThrowingError); Info<< "\nDone" << nl << endl; diff --git a/applications/test/argList/Test-argList.C b/applications/test/argList/Test-argList.C index 4ecc8859f52..bab02975005 100644 --- a/applications/test/argList/Test-argList.C +++ b/applications/test/argList/Test-argList.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License 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; - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); try { label val; @@ -52,7 +52,7 @@ void predicateTests_label(const word& optName, const argList& args) << 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; - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); try { scalar val; @@ -72,7 +72,7 @@ void predicateTests_scalar(const word& optName, const argList& args) << err << nl << endl; } - FatalError.throwExceptions(throwingError); + FatalError.throwing(oldThrowingError); } diff --git a/applications/test/coordinateSystem/Test-coordinateSystem.C b/applications/test/coordinateSystem/Test-coordinateSystem.C index f012bff2ee4..174389b6c62 100644 --- a/applications/test/coordinateSystem/Test-coordinateSystem.C +++ b/applications/test/coordinateSystem/Test-coordinateSystem.C @@ -101,8 +101,8 @@ void doTest(const dictionary& dict) Info<< dict.dictName() << dict << nl; // Could fail? - const bool throwingIOError = FatalIOError.throwExceptions(); - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); + const bool oldThrowingIOErr = FatalIOError.throwing(true); try { @@ -120,8 +120,8 @@ void doTest(const dictionary& dict) { Info<< "Caught FatalError " << err << nl << endl; } - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOError); + FatalError.throwing(oldThrowingError); + FatalIOError.throwing(oldThrowingIOErr); } @@ -130,8 +130,8 @@ void doTest(const objectRegistry& obr, const dictionary& dict) Info<< dict.dictName() << dict << nl; // Could fail? - const bool throwingIOError = FatalIOError.throwExceptions(); - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); + const bool oldThrowingIOErr = FatalIOError.throwing(true); try { @@ -148,8 +148,8 @@ void doTest(const objectRegistry& obr, const dictionary& dict) { Info<< "Caught FatalError " << err << nl << endl; } - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOError); + FatalError.throwing(oldThrowingError); + FatalIOError.throwing(oldThrowingIOErr); } diff --git a/applications/test/dictionary2/Test-dictionary2.C b/applications/test/dictionary2/Test-dictionary2.C index a3eaa6de419..165bdf0726e 100644 --- a/applications/test/dictionary2/Test-dictionary2.C +++ b/applications/test/dictionary2/Test-dictionary2.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -57,8 +57,8 @@ scalar try_readScalar(const dictionary& dict, const word& k) { scalar val(-GREAT); - const bool throwingIOError = FatalIOError.throwExceptions(); - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); + const bool oldThrowingIOerr = FatalIOError.throwing(true); try { @@ -75,8 +75,8 @@ scalar try_readScalar(const dictionary& dict, const word& k) Info<< "readScalar(" << k << ") Caught FatalError " << err << nl << endl; } - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOError); + FatalError.throwing(oldThrowingError); + FatalIOError.throwing(oldThrowingIOerr); return val; } @@ -87,8 +87,8 @@ scalar try_getScalar(const dictionary& dict, const word& k) { scalar val(-GREAT); - const bool throwingIOError = FatalIOError.throwExceptions(); - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); + const bool oldThrowingIOerr = FatalIOError.throwing(true); try { @@ -105,8 +105,8 @@ scalar try_getScalar(const dictionary& dict, const word& k) Info<< "get<scalar>(" << k << ") Caught FatalError " << err << nl << endl; } - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOError); + FatalError.throwing(oldThrowingError); + FatalIOError.throwing(oldThrowingIOerr); return val; } @@ -123,8 +123,8 @@ scalar try_getCheckScalar { scalar val(-GREAT); - const bool throwingIOError = FatalIOError.throwExceptions(); - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); + const bool oldThrowingIOerr = FatalIOError.throwing(true); try { @@ -141,8 +141,8 @@ scalar try_getCheckScalar Info<< "getCheck<scalar>(" << k << ") Caught FatalError " << err << nl << endl; } - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOError); + FatalError.throwing(oldThrowingError); + FatalIOError.throwing(oldThrowingIOerr); return val; } @@ -159,8 +159,8 @@ scalar try_getScalar(const entry* eptr, const word& k) return val; } - const bool throwingIOError = FatalIOError.throwExceptions(); - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); + const bool oldThrowingIOerr = FatalIOError.throwing(true); try { @@ -177,8 +177,8 @@ scalar try_getScalar(const entry* eptr, const word& k) Info<< "entry get<scalar>(" << k << ") Caught FatalError " << err << nl << endl; } - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOError); + FatalError.throwing(oldThrowingError); + FatalIOError.throwing(oldThrowingIOerr); return val; } diff --git a/applications/test/dimensionSet/Test-dimensionSet.C b/applications/test/dimensionSet/Test-dimensionSet.C index b145927c254..52374f0e400 100644 --- a/applications/test/dimensionSet/Test-dimensionSet.C +++ b/applications/test/dimensionSet/Test-dimensionSet.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -94,7 +94,7 @@ unsigned checkDimensions std::string errMsg; // Expect some failures - const bool prev = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); for ( @@ -127,7 +127,7 @@ unsigned checkDimensions hadDimensionError(test, dimsOk, errMsg); } - FatalError.throwExceptions(prev); + FatalError.throwing(oldThrowingError); return nFail; } diff --git a/applications/test/error/Test-error.C b/applications/test/error/Test-error.C index 3e25fe9da0b..2fe8f95a99d 100644 --- a/applications/test/error/Test-error.C +++ b/applications/test/error/Test-error.C @@ -56,8 +56,8 @@ int main(int argc, char *argv[]) if (!args.found("no-throw")) { - FatalIOError.throwExceptions(); - FatalError.throwExceptions(); + FatalIOError.throwing(true); + FatalError.throwing(true); } try diff --git a/applications/test/exprEntry/Test-exprEntry.C b/applications/test/exprEntry/Test-exprEntry.C index 1f14bbf45aa..b2a0dffb55c 100644 --- a/applications/test/exprEntry/Test-exprEntry.C +++ b/applications/test/exprEntry/Test-exprEntry.C @@ -103,8 +103,8 @@ int main(int argc, char *argv[]) { string str(t.stringToken()); - const bool throwingErr = FatalError.throwExceptions(); - const bool throwingIOErr = FatalIOError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); + const bool oldThrowingIOErr = FatalIOError.throwing(true); try { @@ -128,8 +128,8 @@ int main(int argc, char *argv[]) Info<< err.message().c_str() << nl; } - FatalError.throwExceptions(throwingErr); - FatalIOError.throwExceptions(throwingIOErr); + FatalError.throwing(oldThrowingError); + FatalIOError.throwing(oldThrowingIOErr); Info<< nl; } } diff --git a/applications/test/faces/Test-faces.C b/applications/test/faces/Test-faces.C index 7909cac61b6..fab3d04ca15 100644 --- a/applications/test/faces/Test-faces.C +++ b/applications/test/faces/Test-faces.C @@ -148,7 +148,7 @@ int main(int argc, char *argv[]) #if 0 // Expect failure, but triggers abort which cannot be caught - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); try { labelledTri l1({1, 2, 3, 10, 24}); @@ -159,7 +159,7 @@ int main(int argc, char *argv[]) WarningInFunction << "Caught FatalError " << err << nl << endl; } - FatalError.throwExceptions(throwingError); + FatalError.throwing(oldThrowingError); #endif labelledTri l2({1, 2, 3}); diff --git a/applications/test/fileName/Test-fileName.C b/applications/test/fileName/Test-fileName.C index 64888aa1097..8a1568e4a46 100644 --- a/applications/test/fileName/Test-fileName.C +++ b/applications/test/fileName/Test-fileName.C @@ -779,7 +779,7 @@ int main(int argc, char *argv[]) Info<< nl << "Expect a FatalError for findEtcFile() with a bad name:" << nl; - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); try { @@ -792,7 +792,7 @@ int main(int argc, char *argv[]) Info<< nl << "findEtcFile() Caught FatalError " << err << nl << endl; } - FatalError.throwExceptions(throwingError); + FatalError.throwing(oldThrowingError); } diff --git a/applications/test/primitives/Test-primitives.C b/applications/test/primitives/Test-primitives.C index 1fe56e2ae9f..0eb6a071103 100644 --- a/applications/test/primitives/Test-primitives.C +++ b/applications/test/primitives/Test-primitives.C @@ -144,8 +144,8 @@ unsigned testParsing string errMsg; // Expect some failures - const bool prev1 = FatalError.throwExceptions(); - const bool prev2 = FatalIOError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); + const bool oldThrowingIOErr = FatalIOError.throwing(true); for (const std::pair<bool, std::string>& test : tests) { @@ -169,8 +169,8 @@ unsigned testParsing hadParsingError(test, result, errMsg); } - FatalError.throwExceptions(prev1); - FatalIOError.throwExceptions(prev2); + FatalError.throwing(oldThrowingError); + FatalIOError.throwing(oldThrowingIOErr); return nFail; } diff --git a/applications/test/regex1/Test-regex1.C b/applications/test/regex1/Test-regex1.C index 9f917355a96..921b3aa130c 100644 --- a/applications/test/regex1/Test-regex1.C +++ b/applications/test/regex1/Test-regex1.C @@ -110,7 +110,7 @@ void generalTests() string me("Mark"); // Expect some failures: - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); try { @@ -214,7 +214,7 @@ void generalTests() 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; // Expect some failures: - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); // Report matches: for (const auto& testseq : tests) @@ -282,7 +282,7 @@ void testExpressions(const UList<regexTest>& tests) } } - FatalError.throwExceptions(throwingError); + FatalError.throwing(oldThrowingError); } diff --git a/applications/test/string2/Test-string2.C b/applications/test/string2/Test-string2.C index 65368a06705..9186bda26f2 100644 --- a/applications/test/string2/Test-string2.C +++ b/applications/test/string2/Test-string2.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,7 +66,7 @@ void testNumericEvaluation(const std::string& s) << s << nl << "========" << nl; - const bool throwingIOError = FatalIOError.throwExceptions(); + const bool oldThrowingIOErr = FatalIOError.throwing(true); try { @@ -91,7 +91,7 @@ void testNumericEvaluation(const std::string& s) Info<< "========" << nl << nl; - FatalIOError.throwExceptions(throwingIOError); + FatalIOError.throwing(oldThrowingIOErr); } diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index b866b07cb25..7f905226300 100644 --- a/applications/utilities/mesh/manipulation/setSet/setSet.C +++ b/applications/utilities/mesh/manipulation/setSet/setSet.C @@ -813,8 +813,8 @@ int main(int argc, char *argv[]) // Whether to quit bool quit = false; - FatalError.throwExceptions(); - FatalIOError.throwExceptions(); + FatalError.throwing(true); + FatalIOError.throwing(true); do { diff --git a/applications/utilities/miscellaneous/foamHelp/foamHelp.C b/applications/utilities/miscellaneous/foamHelp/foamHelp.C index e95f0853a5a..99ce193b5ca 100644 --- a/applications/utilities/miscellaneous/foamHelp/foamHelp.C +++ b/applications/utilities/miscellaneous/foamHelp/foamHelp.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2014 OpenFOAM Foundation - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -63,7 +63,7 @@ int main(int argc, char *argv[]) word utilityName(argv[1]); autoPtr<helpType> utility; - const bool throwing = FatalError.throwExceptions(); + const bool oldThrowingErr = FatalError.throwing(true); try { utility.reset(helpType::New(utilityName)); @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) << err.message().c_str() << nl << exit(FatalError); } - FatalError.throwExceptions(throwing); + FatalError.throwing(oldThrowingErr); utility().init(); diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundaryTemplates.C b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundaryTemplates.C index 9721c55ea65..43fa15d7920 100644 --- a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundaryTemplates.C +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundaryTemplates.C @@ -105,8 +105,8 @@ void Foam::helpTypes::helpBoundary::fixedValueFieldConditions // throw exceptions to avoid fatal errors when casting from generic patch // type to incompatible patch type - FatalIOError.throwExceptions(); - FatalError.throwExceptions(); + FatalIOError.throwing(true); + FatalError.throwing(true); bool foundFixed = false; forAll(types, i) diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/createMeshAccounting.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/createMeshAccounting.H index 61116489eec..909d3dfedf0 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/createMeshAccounting.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/createMeshAccounting.H @@ -67,7 +67,7 @@ PtrList<ensightFaMesh> ensightMeshesFa(regionNames.size()); { autoPtr<faMesh> faMeshPtr; - const bool throwing = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); try { faMeshPtr.reset(new faMesh(mesh)); @@ -76,7 +76,7 @@ PtrList<ensightFaMesh> ensightMeshesFa(regionNames.size()); { faMeshPtr.reset(nullptr); } - FatalError.throwExceptions(throwing); + FatalError.throwing(oldThrowingError); if (faMeshPtr) { diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H index 9f4b8fc6845..f9f15fb4828 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H @@ -46,7 +46,7 @@ if (doFiniteArea) if (nAreaFields) { - const bool throwing = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); try { faMeshPtr.reset(new faMesh(meshProxy.baseMesh())); @@ -55,7 +55,7 @@ if (doFiniteArea) { faMeshPtr.clear(); } - FatalError.throwExceptions(throwing); + FatalError.throwing(oldThrowingError); } if (faMeshPtr && nAreaFields) diff --git a/applications/utilities/postProcessing/postProcess/postProcess.C b/applications/utilities/postProcessing/postProcess/postProcess.C index d2d03fcb817..1071cec35d2 100644 --- a/applications/utilities/postProcessing/postProcess/postProcess.C +++ b/applications/utilities/postProcessing/postProcess/postProcess.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016 OpenFOAM Foundation - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -233,7 +233,7 @@ int main(int argc, char *argv[]) fields.updateSelection(); - const bool throwingIOErr = FatalIOError.throwExceptions(); + const bool oldThrowingIOErr = FatalIOError.throwing(true); try { @@ -258,7 +258,7 @@ int main(int argc, char *argv[]) Info<< endl; // Restore previous exception throwing state - FatalIOError.throwExceptions(throwingIOErr); + FatalIOError.throwing(oldThrowingIOErr); } Info<< "End\n" << endl; diff --git a/src/OpenFOAM/db/IOobjectList/IOobjectList.C b/src/OpenFOAM/db/IOobjectList/IOobjectList.C index 85439ec787b..3772b23ac06 100644 --- a/src/OpenFOAM/db/IOobjectList/IOobjectList.C +++ b/src/OpenFOAM/db/IOobjectList/IOobjectList.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -137,7 +137,7 @@ Foam::IOobjectList::IOobjectList ); bool ok = false; - const bool throwingIOerr = FatalIOError.throwExceptions(); + const bool oldThrowingIOerr = FatalIOError.throwing(true); try { @@ -149,7 +149,7 @@ Foam::IOobjectList::IOobjectList Warning << err << nl << endl; } - FatalIOError.throwExceptions(throwingIOerr); + FatalIOError.throwing(oldThrowingIOerr); if (ok) { diff --git a/src/OpenFOAM/db/error/error.H b/src/OpenFOAM/db/error/error.H index e7ecf16fbf4..2bd569e7eef 100644 --- a/src/OpenFOAM/db/error/error.H +++ b/src/OpenFOAM/db/error/error.H @@ -159,12 +159,12 @@ public: return throwing_; } - //- Specify exception throwing (default is activate) + //- Specify exception throwing state (on or off) // \return the previous throwing state - bool throwExceptions(bool doThrow = true) noexcept + bool throwing(const bool on) noexcept { - bool old = throwing_; - throwing_ = doThrow; + bool old(throwing_); + throwing_ = on; return old; } @@ -230,6 +230,13 @@ public: // 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 // \return the previous throwing state bool dontThrowExceptions() noexcept diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 1c7f5a91865..4c39aa2759b 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -647,8 +647,8 @@ bool Foam::functionObjectList::execute() { // Throw FatalError, FatalIOError as exceptions - const bool throwingError = FatalError.throwExceptions(); - const bool throwingIOerr = FatalIOError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); + const bool oldThrowingIOerr = FatalIOError.throwing(true); bool hadError = false; @@ -693,8 +693,8 @@ bool Foam::functionObjectList::execute() if (hadError) { // Restore previous state - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOerr); + FatalError.throwing(oldThrowingError); + FatalIOError.throwing(oldThrowingIOerr); continue; } @@ -736,8 +736,8 @@ bool Foam::functionObjectList::execute() } // Restore previous state - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOerr); + FatalError.throwing(oldThrowingError); + FatalIOError.throwing(oldThrowingIOerr); } else { @@ -853,8 +853,8 @@ bool Foam::functionObjectList::end() // Ignore failure on end() - not much we can do anyhow // Throw FatalError, FatalIOError as exceptions - const bool throwingError = FatalError.throwExceptions(); - const bool throwingIOerr = FatalIOError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); + const bool oldThrowingIOerr = FatalIOError.throwing(true); try { @@ -888,8 +888,8 @@ bool Foam::functionObjectList::end() } // Restore previous state - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOerr); + FatalError.throwing(oldThrowingError); + FatalIOError.throwing(oldThrowingIOerr); } } @@ -1083,8 +1083,8 @@ bool Foam::functionObjectList::read() if (enabled && !objPtr) { // Throw FatalError, FatalIOError as exceptions - const bool throwingError = FatalError.throwExceptions(); - const bool throwingIOerr = FatalIOError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); + const bool oldThrowingIOerr = FatalIOError.throwing(true); try { @@ -1148,8 +1148,8 @@ bool Foam::functionObjectList::read() } // Restore previous state - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOerr); + FatalError.throwing(oldThrowingError); + FatalIOError.throwing(oldThrowingIOerr); // Require valid functionObject on all processors if (!returnReduce(bool(objPtr), andOp<bool>())) diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/postProcess.H b/src/OpenFOAM/db/functionObjects/functionObjectList/postProcess.H index 2d9b7307880..a42521f5b27 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/postProcess.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/postProcess.H @@ -140,7 +140,7 @@ if (argList::postProcess(argc, argv)) } } - FatalIOError.throwExceptions(); + FatalIOError.throwing(true); try { diff --git a/tutorials/incompressible/lumpedPointMotion/bridge/code/polynomial-motion.C b/tutorials/incompressible/lumpedPointMotion/bridge/code/polynomial-motion.C index f6280dd0de9..c15a39f067a 100644 --- a/tutorials/incompressible/lumpedPointMotion/bridge/code/polynomial-motion.C +++ b/tutorials/incompressible/lumpedPointMotion/bridge/code/polynomial-motion.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -362,8 +362,8 @@ int main(int argc, char *argv[]) autoPtr<Time> runTimePtr; autoPtr<lumpedPointIOMovement> movementPtr; - const bool throwingIOError = FatalIOError.throwExceptions(); - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingError = FatalError.throwing(true); + const bool oldThrowingIOerr = FatalIOError.throwing(true); try { @@ -380,8 +380,8 @@ int main(int argc, char *argv[]) } Info<< nl << endl; - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOError); + FatalError.throwing(oldThrowingError); + FatalIOError.throwing(oldThrowingIOerr); if (!movementPtr) { diff --git a/tutorials/incompressible/lumpedPointMotion/building/code/building-motion.C b/tutorials/incompressible/lumpedPointMotion/building/code/building-motion.C index 14de04b9ed3..1e4c5c77a94 100644 --- a/tutorials/incompressible/lumpedPointMotion/building/code/building-motion.C +++ b/tutorials/incompressible/lumpedPointMotion/building/code/building-motion.C @@ -408,8 +408,8 @@ int main(int argc, char *argv[]) autoPtr<Time> runTimePtr; autoPtr<lumpedPointIOMovement> movementPtr; - const bool throwingIOError = FatalIOError.throwExceptions(); - const bool throwingError = FatalError.throwExceptions(); + const bool oldThrowingIO = FatalIOError.throwing(true); + const bool oldThrowingEx = FatalError.throwing(true); try { @@ -426,8 +426,8 @@ int main(int argc, char *argv[]) } Info<< nl << endl; - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOError); + FatalError.throwing(oldThrowingEx); + FatalIOError.throwing(oldThrowingIO); if (!movementPtr) { -- GitLab