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
+37 -2
View File
@@ -4,20 +4,53 @@
#include <string> #include <string>
using namespace std; using namespace std;
namespace errorEngine namespace errorEngine
{ {
enum errorLevel_t {debug = 0,warning,error,crash}; enum errorLevel_t {debug = 0,warning,error,crash};
errorLevel_t globalErrLvl = error;
struct errorEngineCreds struct errorEngineCreds
{ {
string errorLocation; string errorLocation;
string errorName; string errorName;
int8_t errorValue; int8_t errorValue;
errorLevel_t errorLevel; 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 struct accessNums_t
{ {
uint8_t deviceNumber=0; uint8_t deviceNumber=0;
@@ -37,6 +70,8 @@ public:
localAccessNums = accessNums; localAccessNums = accessNums;
} }
Device(void); Device(void);
void deviceSet(); void deviceSet()
{
}
void deviceDestroy(); void deviceDestroy();
}; };