1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
/*
functions that handle errors and warnings
*/
#include "ErrorWarning.h"
#include "TimeFunctions.h"
#include "GlobalVariables.h"
void exitWithError(string messageOut, ostream &streamOut1, ostream &streamOut2, int errorInt, Parameters &P)
{
if (P.runThreadN>1)
pthread_mutex_lock(&g_threadChunks.mutexError);
time_t timeCurrent;
time( &timeCurrent);
if (streamOut1.good()) {
streamOut1 << "\n" << messageOut << endl << timeMonthDayTime(timeCurrent) <<" ...... FATAL ERROR, exiting\n" <<flush;
};
if (streamOut2.good()) {
streamOut2 << "\n" << messageOut << endl << timeMonthDayTime(timeCurrent) <<" ...... FATAL ERROR, exiting\n" <<flush;
};
delete P.inOut; //to close files
// if (P.runThreadN>1) pthread_mutex_unlock(&g_threadChunks.mutexError);
exit(errorInt);
};
void warningMessage(string messageOut, ostream &streamOut1, ostream &streamOut2, Parameters &P)
{
if (P.runThreadN>1)
pthread_mutex_lock(&g_threadChunks.mutexError);
if (streamOut1.good()) {
streamOut1 << "!!!!! WARNING: " << messageOut <<endl;
};
if (streamOut2.good()) {
streamOut2 << "!!!!! WARNING: " << messageOut <<endl;
};
if (P.runThreadN>1)
pthread_mutex_unlock(&g_threadChunks.mutexError);
};
|