| 166 | |
| 167 | |
| 168 | void Foam::error::exit(const int errNo) |
| 169 | { |
| 170 | if (!throwExceptions_ && JobInfo::constructed) |
| 171 | { |
| 172 | jobInfo.add("FatalError", operator dictionary()); |
| 173 | jobInfo.exit(); |
| 174 | } |
| 175 | |
| 176 | if (abort_) |
| 177 | { |
| 178 | abort(); |
| 179 | } |
| 180 | |
| 181 | if (Pstream::parRun()) |
| 182 | { |
| 183 | Perr<< endl << *this << endl |
| 184 | << "\nFOAM parallel run exiting\n" << endl; |
| 185 | Pstream::exit(errNo); |
| 186 | } |
| 187 | else |
| 188 | { |
| 189 | if (throwExceptions_) |
| 190 | { |
| 191 | // Make a copy of the error to throw |
| 192 | error errorException(*this); |
| 193 | |
| 194 | // Rewind the message buffer for the next error message |
| 195 | messageStreamPtr_->rewind(); |
| 196 | |
| 197 | throw errorException; |
| 198 | } |
| 199 | else |
| 200 | { |
| 201 | Perr<< endl << *this << endl |
| 202 | << "\nFOAM exiting\n" << endl; |
| 203 | ::exit(1); |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | |
| 209 | void Foam::error::abort() |
no test coverage detected