My Project
ErrorManager.h
Go to the documentation of this file.
1 #ifndef ERRORMANAGER_H
2 #define ERRORMANAGER_H
3 
4 #include <iostream>
5 #include <string>
6 #include <vector>
7 
8 using namespace std;
9 
17 class ErrorMgr
18 {
19 public:
23  ErrorMgr() : errMsg("") {}
24 
29  bool empty() const {
30  return errMsg.empty();
31  }
36  bool exists() const {
37  return not empty();
38  }
39 
43  void clear() {
44  errMsg.clear();
45  }
46 
51  void set(const string& err) {
52  errMsg = err;
53  }
54 
59  const string& get() const {
60  return errMsg;
61  }
62 
67  string& get() {
68  return errMsg;
69  }
70 
71 private:
72  std::string errMsg; // Stores the error message
73 };
74 
75 //class Cats_Exception;
76 
78 #define assertMsg(cond, msg) if (not (cond)) { throw Cats_Exception(msg); }
79 
81 #define assertAsync() assertMsg(isCircuit(), "The LTS does not specify a circuit.")
82 
84 {
85 public:
86  Cats_Exception(const string &what) : eMsg (what) {}
87  const char * what() const throw() {
88  return eMsg.c_str();
89  }
90 private:
91  string eMsg;
92 };
93 
94 #endif // ERRORMANAGER_H
ErrorMgr()
Main constructor (with no error).
Definition: ErrorManager.h:23
Definition: ErrorManager.h:83
void clear()
Cleans the error message (no error).
Definition: ErrorManager.h:43
bool exists() const
Indicates whether there is an error message.
Definition: ErrorManager.h:36
Definition: ErrorManager.h:17
bool empty() const
Indicates whether there is no error.
Definition: ErrorManager.h:29