3DiVi Face SDK  3.24.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups
Error.h
Go to the documentation of this file.
1 
9 #ifndef __PBIO_API__PBIO__ERROR_H_
10 #define __PBIO_API__PBIO__ERROR_H_
11 
12 #include <exception>
13 #include <sstream>
14 #include <string>
15 
16 #include <stdint.h>
17 
18 namespace pbio
19 {
20 
26 class Error : public std::exception
27 {
28 public:
29 
30  virtual ~Error() throw()
31  {
32  // nothing
33  }
34 
36 
37  Error(const uint32_t code, const std::string what)
38  {
39  _code = code;
40  _what = what;
41  }
42 
44 
60  virtual const char* what() const throw()
61  {
62  return _what.c_str();
63  }
64 
65 
81  uint32_t code() const throw()
82  {
83  return _code;
84  }
85 
86 private:
87  uint32_t _code;
88  std::string _what;
89 };
90 
91 } // pbio namespace
92 
93 
94 
95 #define PBI0x3dfb4fe3Assert( code, expr, description ) \
96  do \
97  { \
98  if(!(expr)) \
99  { \
100  throw pbio::Error( \
101  code, \
102  "Assertion '" #expr "' failed (" + std::string(description) + \
103  "), error code: " #code "."); \
104  } \
105  } while(0)
106 
107 
108 #endif // __PBIO_API__PBIO__ERROR_H_
The class of exceptions thrown when errors occur.
Definition: Error.h:26
virtual const char * what() const
Gets a string identifying an error.
Definition: Error.h:60
uint32_t code() const
Gets an error code.
Definition: Error.h:81