Updated error handling system

This commit is contained in:
[ Kristjan Komloši HomePC ]
2016-12-24 15:44:47 +01:00
parent 462eeb9eff
commit afff7bb849

View File

@@ -4,20 +4,53 @@
#include <string>
using namespace std;
namespace errorEngine
{
enum errorLevel_t {debug = 0,warning,error,crash};
errorLevel_t globalErrLvl = error;
struct errorEngineCreds
{
string errorLocation;
string errorName;
int8_t errorValue;
errorLevel_t errorLevel;
bool isCyErrVal;
};
void handleErrors(errorEngineCreds);
void handleErrors(errorEngineCreds eecToEval)
{
switch(eecToEval.errorLevel)
{
case debug:
if (globalErrLvl == debug)
{
cerr << "Debug: " << eecToEval.errorLocation << ": " << eecToEval.errorName << endl;
}
case warning:
if (globalErrLvl == warning)
{
cerr << "Warning: " << eecToEval.errorLocation << ": " << eecToEval.errorName << endl;
}
case error:
if (globalErrLvl == error)
{
cerr << "ERROR: " << eecToEval.errorLocation << ": " << eecToEval.errorName << endl;
}
case crash:
if (globalErrLvl == crash)
{
cerr << "FATAL ERROR: " << eecToEval.errorLocation << ": " << eecToEval.errorName << endl;
cerr << "REQUESTING CRASH!" <<endl;
}
}
}
}
struct accessNums_t
{
uint8_t deviceNumber=0;
@@ -37,6 +70,8 @@ public:
localAccessNums = accessNums;
}
Device(void);
void deviceSet();
void deviceSet()
{
}
void deviceDestroy();
};