DFace SDK  2.0.0
LTM
dface_db_exceptio.h
1 //
2 // Created by asy on 11/24/18.
3 //
4 
5 #ifndef DFACE_DB_EXCEPTIO_H
6 #define DFACE_DB_EXCEPTIO_H
7 #include <iostream>
8 #include <exception>
9 #include "../def.h"
10 using namespace std;
11 
16 class DFACEDB_EXPORTS DFaceDBException : public std::exception {
17 public:
21 const int code;
25 const char* msg;
26 
27 public:
28 DFaceDBException(const char* msg, const int code);
29 const char* what () const throw ();
33 const char* getMsg() const;
37 const int getCode() const;
38 
39 };
40 
41 inline DFaceDBException::DFaceDBException(const char *msg, const int code):msg(msg), code(code){
42 
43 }
44 
45 inline const char* DFaceDBException::what() const throw(){
46  int len = sizeof(msg) + sizeof(code) + 10;
47  char* buff = (char*)malloc(len);
48  sprintf(buff, "%s, %d", msg, code);
49  return buff;
50 }
51 
52 inline const int DFaceDBException::getCode() const {
53  return code;
54 }
55 
56 inline const char* DFaceDBException::getMsg() const {
57  return msg;
58 }
59 
60 
61 
62 #endif //DFACE_DB_EXCEPTIO_H
DFaceDB异常类
Definition: dface_db_exceptio.h:16
const char * msg
错误信息
Definition: dface_db_exceptio.h:25
const int code
错误码
Definition: dface_db_exceptio.h:21
const char * getMsg() const
Definition: dface_db_exceptio.h:56
const int getCode() const
Definition: dface_db_exceptio.h:52