Medial Code Documentation
Loading...
Searching...
No Matches
Macros | Functions
c_api_error.h File Reference

Error handling for C API. More...

#include <dmlc/base.h>
#include <dmlc/logging.h>
#include "c_api_utils.h"

Go to the source code of this file.

Macros

#define API_BEGIN()
 macro to guard beginning and end section of all functions
 
#define API_BEGIN_UNGUARD()   try {
 
#define API_END()
 every function starts with API_BEGIN(); and finishes with API_END()
 
#define CHECK_HANDLE()
 
#define xgboost_CHECK_C_ARG_PTR(out_ptr)
 

Functions

void XGBAPISetLastError (const char *msg)
 Set the last error message needed by C API.
 
int XGBAPIHandleException (const dmlc::Error &e)
 handle exception thrown out
 

Detailed Description

Error handling for C API.

Copyright (c) 2015-2022 by Contributors

Macro Definition Documentation

◆ API_BEGIN

#define API_BEGIN ( )
Value:
try { \
auto __guard = ::xgboost::XGBoostAPIGuard();
Definition c_api_utils.h:177

macro to guard beginning and end section of all functions

◆ API_END

#define API_END ( )
Value:
} catch (dmlc::Error & _except_) { \
return XGBAPIHandleException(_except_); \
} catch (std::exception const &_except_) { \
return XGBAPIHandleException(dmlc::Error(_except_.what())); \
} \
return 0;
int XGBAPIHandleException(const dmlc::Error &e)
handle exception thrown out
Definition c_api_error.h:51
exception class that will be thrown by default logger if DMLC_LOG_FATAL_THROW == 1
Definition logging.h:29

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

◆ CHECK_HANDLE

#define CHECK_HANDLE ( )
Value:
if (handle == nullptr) \
LOG(FATAL) << "DMatrix/Booster has not been initialized or has already been disposed.";

◆ xgboost_CHECK_C_ARG_PTR

#define xgboost_CHECK_C_ARG_PTR (   out_ptr)
Value:
do { \
if (XGBOOST_EXPECT(!(out_ptr), false)) { \
LOG(FATAL) << "Invalid pointer argument: " << #out_ptr; \
} \
} while (0)

Function Documentation

◆ XGBAPIHandleException()

int XGBAPIHandleException ( const dmlc::Error e)
inline

handle exception thrown out

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

◆ XGBAPISetLastError()

void XGBAPISetLastError ( const char *  msg)

Set the last error message needed by C API.

Parameters
msgThe error message to set.