Treelite
c_api_error.cc
Go to the documentation of this file.
1 
8 #include <treelite/c_api_error.h>
9 #include <string>
10 
11 namespace {
12 
13 struct TreeliteAPIErrorEntry {
14  std::string last_error;
15 };
16 
17 using TreeliteAPIErrorStore = treelite::ThreadLocalStore<TreeliteAPIErrorEntry>;
18 
19 } // anonymous namespace
20 
21 const char* TreeliteGetLastError() {
22  return TreeliteAPIErrorStore::Get()->last_error.c_str();
23 }
24 
25 void TreeliteAPISetLastError(const char* msg) {
26  TreeliteAPIErrorStore::Get()->last_error = msg;
27 }
const char * TreeliteGetLastError()
display last error; can be called by multiple threads Note. Each thread will get the last error occur...
Definition: c_api_error.cc:21
Helper class for thread-local storage.
Error handling for C API.
void TreeliteAPISetLastError(const char *msg)
Set the last error message needed by C API.
Definition: c_api_error.cc:25
A thread-local storage.
Definition: thread_local.h:17