Skip to content
Snippets Groups Projects
Commit 44548038 authored by laurence's avatar laurence
Browse files

BUG: IOerror: Only output to IOerror to stream if the stream is not bad

parent e24e08bb
Branches
Tags
No related merge requests found
......@@ -255,28 +255,31 @@ void Foam::IOerror::abort()
Foam::Ostream& Foam::operator<<(Ostream& os, const IOerror& ioErr)
{
os << endl
<< ioErr.title().c_str() << endl
<< ioErr.message().c_str() << endl << endl;
if (!os.bad())
{
os << endl
<< ioErr.title().c_str() << endl
<< ioErr.message().c_str() << endl << endl;
os << "file: " << ioErr.ioFileName().c_str();
os << "file: " << ioErr.ioFileName().c_str();
if (ioErr.ioStartLineNumber() >= 0 && ioErr.ioEndLineNumber() >= 0)
{
os << " from line " << ioErr.ioStartLineNumber()
<< " to line " << ioErr.ioEndLineNumber() << '.';
}
else if (ioErr.ioStartLineNumber() >= 0)
{
os << " at line " << ioErr.ioStartLineNumber() << '.';
}
if (ioErr.ioStartLineNumber() >= 0 && ioErr.ioEndLineNumber() >= 0)
{
os << " from line " << ioErr.ioStartLineNumber()
<< " to line " << ioErr.ioEndLineNumber() << '.';
}
else if (ioErr.ioStartLineNumber() >= 0)
{
os << " at line " << ioErr.ioStartLineNumber() << '.';
}
if (IOerror::level >= 2 && ioErr.sourceFileLineNumber())
{
os << endl << endl
<< " From function " << ioErr.functionName().c_str() << endl
<< " in file " << ioErr.sourceFileName().c_str()
<< " at line " << ioErr.sourceFileLineNumber() << '.';
if (IOerror::level >= 2 && ioErr.sourceFileLineNumber())
{
os << endl << endl
<< " From function " << ioErr.functionName().c_str() << endl
<< " in file " << ioErr.sourceFileName().c_str()
<< " at line " << ioErr.sourceFileLineNumber() << '.';
}
}
return os;
......
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