mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: additional method for switching error throwing on/off (issue #552)
- error::throwExceptions(bool) returning the previous state makes it easier to set and restore states. - throwing() method to query the current handling (if required). - the normal error::throwExceptions() and error::dontThrowExceptions() also return the previous state, to make it easier to restore later.
This commit is contained in:
@ -752,8 +752,10 @@ bool Foam::functionObjectList::read()
|
||||
{
|
||||
autoPtr<functionObject> foPtr;
|
||||
|
||||
FatalError.throwExceptions();
|
||||
FatalIOError.throwExceptions();
|
||||
// Throw FatalError, FatalIOError as exceptions
|
||||
const bool throwingError = FatalError.throwExceptions();
|
||||
const bool throwingIOerr = FatalIOError.throwExceptions();
|
||||
|
||||
try
|
||||
{
|
||||
// New functionObject
|
||||
@ -784,8 +786,10 @@ bool Foam::functionObjectList::read()
|
||||
WarningInFunction
|
||||
<< "Caught FatalError " << err << nl << endl;
|
||||
}
|
||||
FatalError.dontThrowExceptions();
|
||||
FatalIOError.dontThrowExceptions();
|
||||
|
||||
// Restore previous exception throwing state
|
||||
FatalError.throwExceptions(throwingError);
|
||||
FatalIOError.throwExceptions(throwingIOerr);
|
||||
|
||||
if (foPtr.valid())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user