Digital Authentication Framework  6.0.1.37
basic_error.h
Go to the documentation of this file.
1 /*
2  * (c) 2014 Good Technology Corporation. All rights reserved.
3  */
4 
10 #ifndef BASIC_ERROR_H
11 #define BASIC_ERROR_H
13 
14 #include <cstdlib>
15 
22 class BasicError : public DAError
23 {
24 public:
25  BasicError() : m_err(0) {}
26 
27  virtual int getCode()
28  {
29  return m_err;
30  }
31 
36  bool setCode(int e)
37  {
38  m_err = e;
39  return (e==SUCCESS);
40  }
41 
42  virtual void clear()
43  {
45  }
46 
47  virtual void getAsStringUTF8(std::string &out)
48  {
49  switch (getCode())
50  {
51 #if !(DOXYGEN)
52 #define F(code, str) case (code): out = str; break;
53  ALL_ERRORS(F);
54 #undef F
55 #endif
56  default:
57  out = "Unknown error";
58  abort(); /* Should never happen */
59  }
60  }
61 
62 protected:
63  int m_err;
64 };
65 
66 #endif
virtual void getAsStringUTF8(std::string &out)
get error as string message.
Definition: basic_error.h:47
Main C++ interface to authentication device.
int m_err
Error code; see DAError for values.
Definition: basic_error.h:63
bool setCode(int e)
Set error code in error code.
Definition: basic_error.h:36
No error occurred.
Definition: DigitalAuthenticationFramework.h:85
Interface for error reporting.
Definition: DigitalAuthenticationFramework.h:81
virtual int getCode()
get error code
Definition: basic_error.h:27
virtual void clear()
reset the current error state.
Definition: basic_error.h:42
Simple implementation of DAError.
Definition: basic_error.h:22