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 <stdexcept>
11 
13 #define API_BEGIN() try {
16 #define API_END() \
17  } \
18  catch (std::exception & _except_) { \
19  return TreeliteAPIHandleException(_except_); \
20  } \
21  return 0
27 #define API_END_HANDLE_ERROR(Finalize) \
28  } \
29  catch (std::exception & _except_) { \
30  Finalize; \
31  return TreeliteAPIHandleException(_except_); \
32  } \
33  return 0
34 
39 void TreeliteAPISetLastError(char const* msg);
45 inline int TreeliteAPIHandleException(std::exception const& e) {
46  TreeliteAPISetLastError(e.what());
47  return -1;
48 }
49 #endif // TREELITE_C_API_ERROR_H_
int TreeliteAPIHandleException(std::exception const &e)
handle Exception thrown out
Definition: c_api_error.h:45
void TreeliteAPISetLastError(char const *msg)
Set the last error message needed by C API.