allow not stop process in error (#97)

* allow not stop process in error

* fix merge error
This commit is contained in:
Nan Zhu
2019-06-25 13:04:39 -07:00
committed by GitHub
parent a429748e24
commit fc85f776f4
4 changed files with 44 additions and 4 deletions

View File

@@ -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);