Catch all standard exceptions in C API. (#6220)
* `std::bad_alloc` is not guaranteed to be caught.
This commit is contained in:
@@ -16,9 +16,17 @@
|
||||
#else // LOG_CAPI_INVOCATION
|
||||
#define API_BEGIN() try {
|
||||
#endif // LOG_CAPI_INVOCATION
|
||||
|
||||
/*! \brief every function starts with API_BEGIN();
|
||||
and finishes with API_END() or API_END_HANDLE_ERROR */
|
||||
#define API_END() } catch(dmlc::Error &_except_) { return XGBAPIHandleException(_except_); } return 0; // NOLINT(*)
|
||||
#define API_END() \
|
||||
} catch (dmlc::Error & _except_) { \
|
||||
return XGBAPIHandleException(_except_); \
|
||||
} catch (std::exception const &_except_) { \
|
||||
return XGBAPIHandleException(dmlc::Error(_except_.what())); \
|
||||
} \
|
||||
return 0; // NOLINT(*)
|
||||
|
||||
#define CHECK_HANDLE() if (handle == nullptr) \
|
||||
LOG(FATAL) << "DMatrix/Booster has not been intialized or has already been disposed.";
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user