bool isWithLogging() { // If JPACKAGE_DEBUG environment variable is set to "true" // logging is enabled. return SysInfo::getEnvVariable(
std::nothrow, _T("JPACKAGE_DEBUG")) == _T("true");
}
int launch(const std::nothrow_t&,
LauncherFunc func, LogAppender* lastErrorLogAppender) {
if (isWithLogging()) {
Logger::defaultLogger().setAppender(standardLogAppender);
} else {
Logger::defaultLogger().setAppender(nopLogAppender);
}
// This will temporary change log appenders of the default logger // to save log messages in the default and additional log appenders. // Log appenders config of the default logger will be restored to // the original state at function exit automatically. const SetLoggerAtEndOfScope setLogger(withLogAppender, lastErrorLogAppender);
func(); return0;
// The point of all these redefines is to save the last raw error message in // 'theLastErrorMsg' variable. // By default error messages are saved in exception instances with the details // of error origin (source file, function name, line number). // We don't want these details in user error messages. However we still want to // save full information about the last error in the default log appender. #undef JP_HANDLE_ERROR #undef JP_HANDLE_UNKNOWN_ERROR #undef JP_CATCH_EXCEPTIONS #define JP_HANDLE_ERROR(e) \ do { \
errorMsg = (tstrings::any() << e.what()).str(); \
theLastErrorMsg = &errorMsg; \
reportError(JP_SOURCE_CODE_POS, e); \
} while(0) #define JP_HANDLE_UNKNOWN_ERROR \ do { \
errorMsg = "Unknown error"; \
theLastErrorMsg = &errorMsg; \
reportUnknownError(JP_SOURCE_CODE_POS); \
} while(0) #define JP_CATCH_EXCEPTIONS \ catch (const JpErrorBase& e) { \
errorMsg = (tstrings::any() << e.rawMessage()).str(); \
theLastErrorMsg = &errorMsg; \ try { \ throw; \
} catch (const std::runtime_error& e) { \
reportError(JP_SOURCE_CODE_POS, e); \
} \
} catch (const std::runtime_error& e) { \
errorMsg = lastCRTError(); \
theLastErrorMsg = &errorMsg; \
reportError(JP_SOURCE_CODE_POS, e); \
} \
JP_CATCH_UNKNOWN_EXCEPTION
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.