Kallisto Linux API
Library for interacting with Kallisto devices
kallisto_error.hpp
Go to the documentation of this file.
1 
42 #ifndef KALLISTO_ERROR_HPP_
43 #define KALLISTO_ERROR_HPP_
44 
45 /*******************************************************************************
46  * Includes
47  * *****************************************************************************/
48 #include <string>
49 #include <sstream> //std::stringstream
50 
51 namespace kallisto {
52 namespace error {
53 
54 /*******************************************************************************
55  * Library
56  ******************************************************************************/
60  SUCCESS = 0,
78 };
79 
83  private:
84  KallistoResult m_result; // Holds the result code
85  std::string m_message; // Optional message describing why this error ocurred
86 
88  KallistoDetailedResult(const KallistoResult result, const std::string message);
89 
90  public:
93 
96 
99 
102 
105 
112  static KallistoDetailedResult build(const KallistoResult result);
113 
121  static KallistoDetailedResult build(const KallistoResult result, const std::string message);
122 
129  static std::string toString(const KallistoResult result);
130 
136  std::string toString() const;
137 
143  KallistoResult getResult() const;
144 
150  std::string getMessage() const;
151 };
152 
161 void kallisto_error_handler(unsigned int& error_code, const char * file, unsigned int line, const char * function);
162 
163 } /* namespace error */
164 } /* namespace kallisto */
165 
166 
172 #define KALLISTO_ERROR_HANDLER(ERR_CODE) \
173  do \
174  { \
175  kallisto::error::kallisto_error_handler((ERR_CODE), __FILE__, __LINE__, __FUNCTION__); \
176  } while (0)
177 
178 
184 #define KALLISTO_ERROR_CHECK(ERR_CODE) \
185  do \
186  { \
187  unsigned int LOCAL_ERR_CODE = (ERR_CODE); \
188  if (LOCAL_ERR_CODE != 0) \
189  { \
190  KALLISTO_ERROR_HANDLER(LOCAL_ERR_CODE); \
191  } \
192  } while (0)
193 
194 #endif /* KALLISTO_ERROR_HPP_ */
static KallistoDetailedResult build(const KallistoResult result)
No Memory for operation.
Definition: kallisto_error.hpp:61
BLE Device operation error.
Definition: kallisto_error.hpp:76
Invalid Flags.
Definition: kallisto_error.hpp:67
void kallisto_error_handler(unsigned int &error_code, const char *file, unsigned int line, const char *function)
Definition: bluetooth_adapter.hpp:52
Invalid state, operation disallowed in this state.
Definition: kallisto_error.hpp:65
Internal Error.
Definition: kallisto_error.hpp:60
Class that encapsulates a result.
Definition: kallisto_error.hpp:81
KallistoResult
Set of error code defines.
Definition: kallisto_error.hpp:58
Successful command.
Definition: kallisto_error.hpp:59
Invalid Data.
Definition: kallisto_error.hpp:68
Not supported.
Definition: kallisto_error.hpp:63
Null Pointer.
Definition: kallisto_error.hpp:71
Busy.
Definition: kallisto_error.hpp:74
Data size exceeds limit.
Definition: kallisto_error.hpp:69
Operation timed out.
Definition: kallisto_error.hpp:70
Invalid Length.
Definition: kallisto_error.hpp:66
Bad Memory Address.
Definition: kallisto_error.hpp:73
BLE Adapter operation error.
Definition: kallisto_error.hpp:75
Invalid Parameter.
Definition: kallisto_error.hpp:64
Not found.
Definition: kallisto_error.hpp:62
KallistoDetailedResult & operator=(const KallistoDetailedResult &other)
Forbidden Operation.
Definition: kallisto_error.hpp:72