Treelite
Macros | Functions
c_api_error.h File Reference

Error handling for C API. More...

#include <treelite/c_api_common.h>
#include <stdexcept>
Include dependency graph for c_api_error.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define API_BEGIN()   try {
 macro to guard beginning and end section of all functions
 
#define API_END()
 every function starts with API_BEGIN(); and finishes with API_END() or API_END_HANDLE_ERROR More...
 
#define API_END_HANDLE_ERROR(Finalize)
 every function starts with API_BEGIN(); and finishes with API_END() or API_END_HANDLE_ERROR() "Finalize" contains procedure to cleanup states when an error happens More...
 

Functions

void TreeliteAPISetLastError (const char *msg)
 Set the last error message needed by C API. More...
 
int TreeliteAPIHandleException (const std::exception &e)
 handle exception thrown out More...
 

Detailed Description

Error handling for C API.

Copyright (c) 2017-2021 by Contributors

Author
Hyunsu Cho

Definition in file c_api_error.h.

Macro Definition Documentation

◆ API_END

#define API_END ( )
Value:
} catch(std::exception &_except_) { \
return TreeliteAPIHandleException(_except_); \
} \
return 0
int TreeliteAPIHandleException(const std::exception &e)
handle exception thrown out
Definition: c_api_error.h:44

every function starts with API_BEGIN(); and finishes with API_END() or API_END_HANDLE_ERROR

Definition at line 17 of file c_api_error.h.

◆ API_END_HANDLE_ERROR

#define API_END_HANDLE_ERROR (   Finalize)
Value:
} catch(std::exception &_except_) { \
Finalize; \
return TreeliteAPIHandleException(_except_); \
} \
return 0
int TreeliteAPIHandleException(const std::exception &e)
handle exception thrown out
Definition: c_api_error.h:44

every function starts with API_BEGIN(); and finishes with API_END() or API_END_HANDLE_ERROR() "Finalize" contains procedure to cleanup states when an error happens

Definition at line 27 of file c_api_error.h.

Function Documentation

◆ TreeliteAPIHandleException()

int TreeliteAPIHandleException ( const std::exception &  e)
inline

handle exception thrown out

Parameters
ethe exception
Returns
the return value of API after exception is handled

Definition at line 44 of file c_api_error.h.

◆ TreeliteAPISetLastError()

void TreeliteAPISetLastError ( const char *  msg)

Set the last error message needed by C API.

Parameters
msgThe error message to set.

Definition at line 32 of file c_api_error.cc.