allow not stop process in error (#97)
* allow not stop process in error * fix merge error
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
#ifndef RABIT_STRICT_CXX98_
|
||||
@@ -61,22 +62,36 @@ namespace utils {
|
||||
/*! \brief error message buffer length */
|
||||
const int kPrintBuffer = 1 << 12;
|
||||
|
||||
/*! \brief we may want to keep the process alive when there are multiple workers
|
||||
* co-locate in the same process */
|
||||
extern bool STOP_PROCESS_ON_ERROR;
|
||||
|
||||
#ifndef RABIT_CUSTOMIZE_MSG_
|
||||
/*!
|
||||
* \brief handling of Assert error, caused by inappropriate input
|
||||
* \param msg error message
|
||||
*/
|
||||
inline void HandleAssertError(const char *msg) {
|
||||
fprintf(stderr, "AssertError:%s\n", msg);
|
||||
exit(-1);
|
||||
if (STOP_PROCESS_ON_ERROR) {
|
||||
fprintf(stderr, "AssertError:%s, shutting down process\n", msg);
|
||||
exit(-1);
|
||||
} else {
|
||||
fprintf(stderr, "AssertError:%s, rabit is configured to keep process running\n", msg);
|
||||
throw std::runtime_error(msg);
|
||||
}
|
||||
}
|
||||
/*!
|
||||
* \brief handling of Check error, caused by inappropriate input
|
||||
* \param msg error message
|
||||
*/
|
||||
inline void HandleCheckError(const char *msg) {
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
exit(-1);
|
||||
if (STOP_PROCESS_ON_ERROR) {
|
||||
fprintf(stderr, "%s, shutting down process", msg);
|
||||
exit(-1);
|
||||
} else {
|
||||
fprintf(stderr, "%s, rabit is configured to keep process running\n", msg);
|
||||
throw std::runtime_error(msg);
|
||||
}
|
||||
}
|
||||
inline void HandlePrint(const char *msg) {
|
||||
printf("%s", msg);
|
||||
|
||||
Reference in New Issue
Block a user