Commit a5cc0ffc authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: use const reference for caught exceptions

parent a50c4468
......@@ -183,7 +183,7 @@ int main(int argc, char *argv[])
<< "(non-const)\n";
}
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< "Failed (expected) " << err << nl << endl;
}
......@@ -205,7 +205,7 @@ int main(int argc, char *argv[])
Info<< "[20] is false, as expected for const-access\n";
}
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< "Failed (expected) " << err << nl << endl;
}
......@@ -275,7 +275,7 @@ int main(int argc, char *argv[])
list1[16] = 5;
list1[36] = list1.max_value;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< "Failed (expected) " << err << nl << endl;
......
......@@ -201,7 +201,7 @@ int main(int argc, char *argv[])
Info<<"Random position(10,5): "
<< Random().position<label>(10, 5) << endl;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< "Caught FatalError " << err << nl << endl;
}
......
......@@ -108,11 +108,11 @@ void doTest(const dictionary& dict)
basicTests(cs1);
}
catch (Foam::IOerror& err)
catch (const Foam::IOerror& err)
{
Info<< "Caught FatalIOError " << err << nl << endl;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< "Caught FatalError " << err << nl << endl;
}
......@@ -136,11 +136,11 @@ void doTest(const objectRegistry& obr, const dictionary& dict)
basicTests(cs1);
}
catch (Foam::IOerror& err)
catch (const Foam::IOerror& err)
{
Info<< "Caught FatalIOError " << err << nl << endl;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< "Caught FatalError " << err << nl << endl;
}
......
......@@ -61,12 +61,12 @@ scalar try_readScalar(const dictionary& dict, const word& k)
val = readScalar(dict.lookup(k));
Info<< "readScalar(" << k << ") = " << val << nl;
}
catch (Foam::IOerror& err)
catch (const Foam::IOerror& err)
{
Info<< "readScalar(" << k << ") Caught FatalIOError "
<< err << nl << endl;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< "readScalar(" << k << ") Caught FatalError "
<< err << nl << endl;
......@@ -91,12 +91,12 @@ scalar try_getScalar(const dictionary& dict, const word& k)
val = dict.get<scalar>(k);
Info<< "get<scalar>(" << k << ") = " << val << nl;
}
catch (Foam::IOerror& err)
catch (const Foam::IOerror& err)
{
Info<< "get<scalar>(" << k << ") Caught FatalIOError "
<< err << nl << endl;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< "get<scalar>(" << k << ") Caught FatalError "
<< err << nl << endl;
......@@ -127,12 +127,12 @@ scalar try_getScalar(const entry* eptr, const word& k)
val = eptr->get<scalar>();
Info<< "entry get<scalar>(" << k << ") = " << val << nl;
}
catch (Foam::IOerror& err)
catch (const Foam::IOerror& err)
{
Info<< "entry get<scalar>(" << k << ") Caught FatalIOError "
<< err << nl << endl;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< "entry get<scalar>(" << k << ") Caught FatalError "
<< err << nl << endl;
......
......@@ -112,7 +112,7 @@ unsigned checkDimensions
clip(a, b);
dimsOk = true;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
errMsg = err.message();
}
......
......@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
<< "Error 2"
<< exit(FatalError);
}
catch (Foam::error& fErr)
catch (const Foam::error& fErr)
{
Serr<< "Caught Foam error " << fErr << nl << endl;
}
......@@ -66,7 +66,7 @@ int main(int argc, char *argv[])
<< "Error# 3"
<< exit(FatalError);
}
catch (Foam::error& fErr)
catch (const Foam::error& fErr)
{
Serr<< "Caught Foam error " << fErr << nl << endl;
}
......
......@@ -120,7 +120,7 @@ int main(int argc, char *argv[])
labelledTri l1{ 1, 2, 3, 10, 24 };
Info<< "labelled:" << l1 << nl;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
WarningInFunction
<< "Caught FatalError " << err << nl << endl;
......
......@@ -783,7 +783,7 @@ int main(int argc, char *argv[])
<< findEtcFile("<very-badName>", true) << nl
<< endl;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< nl << "findEtcFile() Caught FatalError "
<< err << nl << endl;
......
......@@ -107,7 +107,7 @@ unsigned testParsing
result.second = function (test.second);
result.first = true;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
errMsg = err.message();
}
......
......@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
}
Info<< endl;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< "Caught FatalError " << err << nl << endl;
continue;
......@@ -164,7 +164,7 @@ int main(int argc, char *argv[])
Info<< "pass - null pointer is no expression" << endl;
}
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< "Caught FatalError " << err << nl << endl;
}
......@@ -181,7 +181,7 @@ int main(int argc, char *argv[])
Info<< "no match" << endl;
}
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< "Caught FatalError " << err << nl << endl;
}
......@@ -198,7 +198,7 @@ int main(int argc, char *argv[])
Info<< "no match" << endl;
}
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< "Caught FatalError " << err << nl << endl;
}
......@@ -215,7 +215,7 @@ int main(int argc, char *argv[])
Info<< "no match" << endl;
}
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< "Caught FatalError " << err << nl << endl;
}
......@@ -232,7 +232,7 @@ int main(int argc, char *argv[])
Info<< "pass - no match on empty expression" << endl;
}
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< "Caught FatalError " << err << nl << endl;
}
......@@ -249,7 +249,7 @@ int main(int argc, char *argv[])
Info<< "pass - no match on empty expression" << endl;
}
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
Info<< "Caught FatalError " << err << nl << endl;
}
......
......@@ -525,7 +525,7 @@ bool doCommand
}
}
}
catch (Foam::IOerror& fIOErr)
catch (const Foam::IOerror& fIOErr)
{
ok = false;
......@@ -536,7 +536,7 @@ bool doCommand
Pout<< topoSetSource::usage(sourceType).c_str();
}
}
catch (Foam::error& fErr)
catch (const Foam::error& fErr)
{
ok = false;
......
......@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
{
utility.reset(helpType::New(utilityName));
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
utility.clear();
......
......@@ -47,7 +47,7 @@ if (doFiniteArea)
{
faMeshPtr.reset(new faMesh(meshProxy.baseMesh()));
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
faMeshPtr.clear();
}
......
......@@ -286,12 +286,12 @@ void Foam::vtkPVFoam::convertVolFields
// Convert
convertVolField(patchInterpList, fld);
}
catch (Foam::IOerror& ioErr)
catch (const Foam::IOerror& ioErr)
{
ioErr.write(Warning, false);
Info<< nl << endl;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
// Bit of trickery to get the original message
err.write(Warning, false);
......@@ -368,12 +368,12 @@ void Foam::vtkPVFoam::convertDimFields
convertVolField(patchInterpList, volFld);
}
catch (Foam::IOerror& ioErr)
catch (const Foam::IOerror& ioErr)
{
ioErr.write(Warning, false);
Info<< nl << endl;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
// Bit of trickery to get the original message
err.write(Warning, false);
......@@ -496,12 +496,12 @@ void Foam::vtkPVFoam::convertAreaFields
dataset->GetCellData()->AddArray(cdata);
}
}
catch (Foam::IOerror& ioErr)
catch (const Foam::IOerror& ioErr)
{
ioErr.write(Warning, false);
Info<< nl << endl;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
// Bit of trickery to get the original message
err.write(Warning, false);
......@@ -638,12 +638,12 @@ void Foam::vtkPVFoam::convertPointFields
dataset->GetPointData()->AddArray(pdata);
}
}
catch (Foam::IOerror& ioErr)
catch (const Foam::IOerror& ioErr)
{
ioErr.write(Warning, false);
Info<< nl << endl;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
// Bit of trickery to get the original message
err.write(Warning, false);
......@@ -817,12 +817,12 @@ void Foam::vtkPVFoam::convertLagrangianFields
vtkmesh->GetCellData()->AddArray(data);
vtkmesh->GetPointData()->AddArray(data);
}
catch (Foam::IOerror& ioErr)
catch (const Foam::IOerror& ioErr)
{
ioErr.write(Warning, false);
Info<< nl << endl;
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
// Bit of trickery to get the original message
err.write(Warning, false);
......
......@@ -226,9 +226,9 @@ int main(int argc, char *argv[])
// Report to output (avoid overwriting values from simulation)
profiling::print(Info);
}
catch (Foam::IOerror& err)
catch (const Foam::IOerror& err)
{
Warning<< err << endl;
Warning << err << endl;
}
Info<< endl;
......
......@@ -141,10 +141,9 @@ Foam::IOobjectList::IOobjectList
// Use object with local scope and current instance (no searching)
ok = objectPtr->typeHeaderOk<IOList<label>>(false, false);
}
catch (Foam::IOerror& err)
catch (const Foam::IOerror& err)
{
Warning
<< err << nl << endl;
Warning << err << nl << endl;
}
FatalIOError.throwExceptions(throwingIOerr);
......
......@@ -170,7 +170,7 @@ void Foam::IFstream::rewind()
{
gzPtr = dynamic_cast<igzstream*>(allocatedPtr_);
}
catch (std::bad_cast&)
catch (const std::bad_cast&)
{
gzPtr = nullptr;
}
......
......@@ -805,12 +805,12 @@ bool Foam::functionObjectList::read()
foPtr = functionObject::New(key, time_, dict);
}
}
catch (Foam::IOerror& ioErr)
catch (const Foam::IOerror& ioErr)
{
Info<< ioErr << nl << endl;
::exit(1);
}
catch (Foam::error& err)
catch (const Foam::error& err)
{
// Bit of trickery to get the original message
err.write(Warning, false);
......
......@@ -149,7 +149,7 @@ if (argList::postProcess(argc, argv))
// Report to output (avoid overwriting values from simulation)
profiling::print(Info);
}
catch (IOerror& err)
catch (const IOerror& err)
{
Warning<< err << endl;
}
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2018-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -88,7 +88,7 @@ inline To& dynamicCast(From& r)
{
return dynamic_cast<To&>(r);
}
catch (std::bad_cast&)
catch (const std::bad_cast&)
{
FatalErrorInFunction
<< "Attempt to cast type " << typeid(r).name()
......@@ -109,7 +109,7 @@ inline To& dynamicCast(From& r, const dictionary& d)
{
return dynamic_cast<To&>(r);
}
catch (std::bad_cast&)
catch (const std::bad_cast&)
{
FatalIOErrorInFunction(d)
<< "Attempt to cast type " << typeid(r).name()
......@@ -131,7 +131,7 @@ inline To& refCast(From& r)
{
return dynamic_cast<To&>(r);
}
catch (std::bad_cast&)
catch (const std::bad_cast&)
{
FatalErrorInFunction
<< "Attempt to cast type " << r.type()
......@@ -153,7 +153,7 @@ inline To& refCast(From& r, const dictionary& d)
{
return dynamic_cast<To&>(r);
}
catch (std::bad_cast&)
catch (const std::bad_cast&)
{
FatalIOErrorInFunction(d)
<< "Attempt to cast type " << r.type()
......
Markdown is supported
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