Treelite
c_api_error.h
Go to the documentation of this file.
1 
7 #ifndef TREELITE_C_API_ERROR_H_
8 #define TREELITE_C_API_ERROR_H_
9 
10 #include <treelite/c_api_common.h>
11 #include <stdexcept>
12 
14 #define API_BEGIN() try {
15 
17 #define API_END() \
18  } catch(std::exception &_except_) { \
19  return TreeliteAPIHandleException(_except_); \
20  } \
21  return 0
22 
27 #define API_END_HANDLE_ERROR(Finalize) \
28  } catch(std::exception &_except_) { \
29  Finalize; \
30  return TreeliteAPIHandleException(_except_); \
31  } \
32  return 0
33 
38 void TreeliteAPISetLastError(const char* msg);
44 inline int TreeliteAPIHandleException(const std::exception &e) {
45  TreeliteAPISetLastError(e.what());
46  return -1;
47 }
48 #endif // TREELITE_C_API_ERROR_H_
int TreeliteAPIHandleException(const std::exception &e)
handle exception thrown out
Definition: c_api_error.h:44
void TreeliteAPISetLastError(const char *msg)
Set the last error message needed by C API.
Definition: c_api_error.cc:21
C API of Treelite, used for interfacing with other languages This header is used by both the runtime ...