3DiVi Face SDK  3.20.0
 Указатель Классы Пространства имен Файлы Функции Переменные Определения типов Перечисления Элементы перечислений Свойства Группы
ExceptionCheck.h
1 #ifndef __ExceptionCheck_h_7f6db1a3a9994e3382e6b4d5c3fd2fd7
2 #define __ExceptionCheck_h_7f6db1a3a9994e3382e6b4d5c3fd2fd7
3 
5 
6 #include <sstream>
7 
8 #include "Error.h"
9 #include "DllHandle.h"
10 
11 namespace pbio
12 {
13 
14 class ExceptionDestroyer
15 {
16 public:
17 
18  ExceptionDestroyer(
19  void* exception,
20  const pbio::import::DllHandle &dll_handle) :
21  exception(exception),
22  dll_handle(dll_handle)
23  {
24 
25  }
26 
27  ~ExceptionDestroyer()
28  {
29  if(exception)
30  dll_handle.apiObject_destructor(exception);
31  }
32 
33 private:
34 
35  void* const exception;
36  const pbio::import::DllHandle &dll_handle;
37 };
38 
39 inline
40 void checkException(
41  void* exception,
42  const pbio::import::DllHandle &dll_handle)
43 {
44  const ExceptionDestroyer ex_de(exception, dll_handle);
45 
46  if(exception)
47  {
48  const std::string what = dll_handle.apiException_what(exception);
49 
50  const uint32_t code = dll_handle.apiException_code(exception);
51 
52  throw pbio::Error(code, what);
53  }
54 }
55 
56 } // pbio namespace
57 
59 
60 #endif // __ExceptionCheck_h_7f6db1a3a9994e3382e6b4d5c3fd2fd7
Error - класс исключений, выбрасываемых при возникновении ошибок.
Класс исключений, выбрасываемых при возникновении ошибок.
Definition: Error.h:26