Face SDK  1.13.0 Mozart release
Face Recognition Software Development Kit
exception.h
Go to the documentation of this file.
1 
4 #ifndef FACE_SDK_EXCEPTION_H
5 #define FACE_SDK_EXCEPTION_H
6 
7 #include <face_sdk_base/export.h>
8 
9 #include <exception>
10 #include <string>
11 
12 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32)
13 #pragma warning(push)
14 
15 // For correct working on android platform need to export face_sdk::exception.
16 // In other case we will have RTTI problems in out tests.
17 // Since we have exported face_sdk_exception, it is also good to export
18 // the symbol of the classes that are used inside the class, in out case class std::string.
19 // We couldn't do that. Prefer to disable this warning.
20 #pragma warning(disable:4275)
21 #pragma warning(disable:4251)
22 #endif
23 
24 namespace face_sdk
25 {
56  class FACE_SDK_EXPORT exception : public std::exception
57  {
58  public:
59 
60  exception();
61 
62  exception(const std::string &message, int code);
63 
64  std::string type_name() const;
65 
66  int32_t code() const;
67 
68  virtual const char* what() const noexcept override;
69 
70  protected:
71 
72  std::string _message;
73  std::string _type_name;
74  int32_t _code;
75  };
76 
77 #define DEFINE_FACE_SDK_EXCEPTION(x, code) \
78  \
79  class FACE_SDK_EXPORT x : public face_sdk::exception \
80  { \
81  public: \
82  x() : exception() \
83  { _type_name = std::string(#x); _code = (code); } \
84  \
85  explicit x(const std::string &message) \
86  : exception(message, (code)) \
87  { _type_name = std::string(#x); _code = (code); } \
88  }
89 
90  DEFINE_FACE_SDK_EXCEPTION(runtime_exception, 1000);
91 
92  DEFINE_FACE_SDK_EXCEPTION(internal_error_exception, 1001);
93 
94  DEFINE_FACE_SDK_EXCEPTION(out_of_range_exception, 1002);
95 
96  DEFINE_FACE_SDK_EXCEPTION(invalid_parameter_exception, 1003);
97 
98  DEFINE_FACE_SDK_EXCEPTION(file_exception, 1004);
99 
100  DEFINE_FACE_SDK_EXCEPTION(file_not_found_exception, 1005);
101 
102  DEFINE_FACE_SDK_EXCEPTION(bad_image_data_exception, 1006);
103 
104  DEFINE_FACE_SDK_EXCEPTION(bad_image_format_exception, 1007);
105 
106  DEFINE_FACE_SDK_EXCEPTION(signature_mismatch_exception, 1008);
107 
108  DEFINE_FACE_SDK_EXCEPTION(incompatible_version_exception, 1009);
109 
110  DEFINE_FACE_SDK_EXCEPTION(version_not_available_exception, 1010);
111 
112  DEFINE_FACE_SDK_EXCEPTION(key_not_found_exception, 1011);
113 
114  DEFINE_FACE_SDK_EXCEPTION(key_exists_exception, 1012);
115 
116  DEFINE_FACE_SDK_EXCEPTION(data_container_corrupted_exception, 1013);
117 
118  DEFINE_FACE_SDK_EXCEPTION(data_container_entries_limit_exceed_exception, 1014);
119 
120  DEFINE_FACE_SDK_EXCEPTION(not_implemented_exception, 1015);
121 
122  DEFINE_FACE_SDK_EXCEPTION(license_exception, 1016);
123 
124  DEFINE_FACE_SDK_EXCEPTION(nvml_exception, 1017);
125 
126  DEFINE_FACE_SDK_EXCEPTION(platofrm_not_supported_exception, 1018);
127 
128  DEFINE_FACE_SDK_EXCEPTION(not_supported_exception, 1019);
129 
130  DEFINE_FACE_SDK_EXCEPTION(make_builder_exception, 1020);
131 
132  DEFINE_FACE_SDK_EXCEPTION(make_image_compressor_exception, 1021);
133 
134  DEFINE_FACE_SDK_EXCEPTION(image_compressor_runtime_exception, 1022);
135 
136  DEFINE_FACE_SDK_EXCEPTION(alignment_info_additional_data_exception, 1023);
137 
138  DEFINE_FACE_SDK_EXCEPTION(face_out_of_bounds_not_set_exception, 1024);
139 
140  DEFINE_FACE_SDK_EXCEPTION(net_runtime_exception, 1025);
141 
142  DEFINE_FACE_SDK_EXCEPTION(make_net_exception, 1026);
143 
144  DEFINE_FACE_SDK_EXCEPTION(make_fir_matcher_exception, 1027);
145 
146  DEFINE_FACE_SDK_EXCEPTION(make_age_gender_exception, 1028);
147 
148  DEFINE_FACE_SDK_EXCEPTION(age_gender_runtime_exception, 1029);
149 
150  DEFINE_FACE_SDK_EXCEPTION(make_alignment_exception, 1030);
151 
152  DEFINE_FACE_SDK_EXCEPTION(make_quality_checker_exception, 1031);
153 
154  DEFINE_FACE_SDK_EXCEPTION(quality_checker_runtime_exception, 1032);
155 
156  DEFINE_FACE_SDK_EXCEPTION(make_detector_exception, 1033);
157 
158  DEFINE_FACE_SDK_EXCEPTION(detect_faces_exception, 1034);
159 
160  DEFINE_FACE_SDK_EXCEPTION(make_face_recognition_exception, 1035);
161 
162  DEFINE_FACE_SDK_EXCEPTION(make_nn_checker_exception, 1036);
163 
164  DEFINE_FACE_SDK_EXCEPTION(nn_checker_runtime_exception, 1037);
165 
166  DEFINE_FACE_SDK_EXCEPTION(frame_process_exception, 1038);
167 
168  DEFINE_FACE_SDK_EXCEPTION(make_red_eyes_checker_exception, 1039);
169 
170  DEFINE_FACE_SDK_EXCEPTION(red_eyes_checker_runtime_exception, 1040);
171 
172  DEFINE_FACE_SDK_EXCEPTION(make_face_color_checker_exception, 1041);
173 
174  DEFINE_FACE_SDK_EXCEPTION(face_color_checker_runtime_exception, 1042);
175 
176  DEFINE_FACE_SDK_EXCEPTION(make_background_checker_exception, 1043);
177 
178  DEFINE_FACE_SDK_EXCEPTION(background_checker_runtime_exception, 1044);
179 
180  DEFINE_FACE_SDK_EXCEPTION(make_mask_checker_exception, 1045);
181 
182  DEFINE_FACE_SDK_EXCEPTION(mask_checker_runtime_exception, 1046);
183 
184  DEFINE_FACE_SDK_EXCEPTION(http_client_exception, 1047);
185 
186  DEFINE_FACE_SDK_EXCEPTION(make_liveness_exception, 1048);
187 
188  DEFINE_FACE_SDK_EXCEPTION(make_pure_fir_extractor_exception, 1049);
189 
190  DEFINE_FACE_SDK_EXCEPTION(make_fir_matching_score_table_exception, 1050);
191 
192  DEFINE_FACE_SDK_EXCEPTION(keychain_exception, 1051);
193 
194  #define UPSCALE_TOO_MUCH_EXCEPTION_CODE 2000
195 
196  class FACE_SDK_EXPORT upscale_too_much_exception : public exception
197  {
198  private:
199  uint32_t _idx;
200  public:
201  upscale_too_much_exception(const std::string &message, uint32_t idx) : exception(message, UPSCALE_TOO_MUCH_EXCEPTION_CODE)
202  {
203  _type_name = "upscale_too_much_exception";
204  _idx = idx;
205  }
206 
207  uint32_t imageIdx()
208  {
209  return _idx;
210  }
211  };
212 
213 
214  std::string FACE_SDK_EXPORT format_exception(const face_sdk::exception& e, int level = 0);
215 
216  bool FACE_SDK_EXPORT is_root_exception_of_type(const std::type_info &tp, const face_sdk::exception &e);
217 
218  void FACE_SDK_EXPORT rethrow_root_exception(const face_sdk::exception& e);
219 
222 #define FACE_SDK_RETHROW_ROOT(x) try{ x; } catch (const face_sdk::exception &exp ) { rethrow_root_exception(exp); }
223 }
224 
225 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32)
226 #pragma warning(pop)
227 #endif
228 
229 #endif //FACE_SDK_EXCEPTION_H
Definition: alignment_info.h:8
Base FaceSDK exception class. Almost all exceptions that FaceSDK throws are inherits this class...
Definition: exception.h:56