From 47d3f1c31d7f1079d39fc3fdb8fdd73ff7fe2906 Mon Sep 17 00:00:00 2001 From: henry Date: Thu, 17 Sep 2009 16:56:27 +0100 Subject: [PATCH] Improved IOerror in the same manner as error --- src/OpenFOAM/db/error/IOerror.C | 25 ++++++++++++++++++------- src/OpenFOAM/db/error/error.C | 2 +- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/OpenFOAM/db/error/IOerror.C b/src/OpenFOAM/db/error/IOerror.C index 5844812369..8cf960fee4 100644 --- a/src/OpenFOAM/db/error/IOerror.C +++ b/src/OpenFOAM/db/error/IOerror.C @@ -139,10 +139,7 @@ void Foam::IOerror::exit(const int) if (abort_) { - Perr<< endl << *this << endl - << "\nFOAM aborting (FOAM_ABORT set)\n" << endl; - printStack(Perr); - ::abort(); + abort(); } if (Pstream::parRun()) @@ -155,7 +152,13 @@ void Foam::IOerror::exit(const int) { if (throwExceptions_) { - throw *this; + // Make a copy of the error to throw + IOerror errorException(*this); + + // Rewind the message buffer for the next error message + messageStreamPtr_->rewind(); + + throw errorException; } else { @@ -194,7 +197,13 @@ void Foam::IOerror::abort() { if (throwExceptions_) { - throw *this; + // Make a copy of the error to throw + IOerror errorException(*this); + + // Rewind the message buffer for the next error message + messageStreamPtr_->rewind(); + + throw errorException; } else { @@ -209,7 +218,9 @@ void Foam::IOerror::abort() Foam::Ostream& Foam::operator<<(Ostream& os, const IOerror& ioErr) { - os << endl << ioErr.message().c_str() << endl << endl; + os << endl + << ioErr.title().c_str() << endl + << ioErr.message().c_str() << endl << endl; os << "file: " << ioErr.ioFileName().c_str(); diff --git a/src/OpenFOAM/db/error/error.C b/src/OpenFOAM/db/error/error.C index ed3502f9b6..72d7a6f198 100644 --- a/src/OpenFOAM/db/error/error.C +++ b/src/OpenFOAM/db/error/error.C @@ -240,7 +240,7 @@ void Foam::error::abort() // Rewind the message buffer for the next error message messageStreamPtr_->rewind(); - throw *this; + throw errorException; } else {