treelite
Macros | Functions
c_api_error.h File Reference

Error handling for C API. More...

#include <dmlc/base.h>
#include <dmlc/logging.h>
#include <treelite/c_api_common.h>
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 dmlc::Error &e)
 handle exception thrown out More...
 

Detailed Description

Error handling for C API.

Copyright (c) 2017 by Contributors

Author
Philip Cho

Definition in file c_api_error.h.

Macro Definition Documentation

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

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

Definition at line 18 of file c_api_error.h.

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

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 28 of file c_api_error.h.

Function Documentation

int TreeliteAPIHandleException ( const dmlc::Error &  e)
inline

handle exception thrown out

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

Definition at line 45 of file c_api_error.h.

void TreeliteAPISetLastError ( const char *  msg)

Set the last error message needed by C API.

Parameters
msgThe error message to set.

Definition at line 20 of file c_api_error.cc.