Skip to content

Commit dd7eabe

Browse files
committed
Test code for feature/improve-crashlog branch
1 parent 7bfe896 commit dd7eabe

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/cli/daemoncommand.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,20 @@ static double GetDebugWorkerDelay()
210210
}
211211
#endif /* I2_DEBUG */
212212

213+
void throw_test_exception() {
214+
if (!Utility::GetFromEnvironment("DEBUG_ABORT").IsEmpty()) {
215+
abort();
216+
}
217+
if (!Utility::GetFromEnvironment("DEBUG_THROW_CXX").IsEmpty()) {
218+
throw std::runtime_error("test exception");
219+
}
220+
#ifdef _WIN32
221+
if (!Utility::GetFromEnvironment("DEBUG_THROW_SEH").IsEmpty()) {
222+
RaiseException(42, 0, 0, nullptr);
223+
}
224+
#endif
225+
}
226+
213227
/**
214228
* Do the actual work (config loading, ...)
215229
*
@@ -285,6 +299,8 @@ int RunWorker(const std::vector<std::string>& configs, bool closeConsoleLog = fa
285299
}
286300
}
287301

302+
throw_test_exception();
303+
288304
/* Create the internal API object storage. Do this here too with setups without API. */
289305
ConfigObjectUtility::CreateStorage();
290306

@@ -520,8 +536,10 @@ static pid_t StartUnixWorker(const std::vector<std::string>& configs, bool close
520536
_exit(RunWorker(configs, closeConsoleLog, stderrFile));
521537
} catch (const std::exception& ex) {
522538
Log(LogCritical, "cli") << "Exception in main process: " << DiagnosticInformation(ex);
539+
throw;
523540
_exit(EXIT_FAILURE);
524541
} catch (...) {
542+
throw;
525543
_exit(EXIT_FAILURE);
526544
}
527545

@@ -687,8 +705,10 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
687705
return RunWorker(configs);
688706
} catch (const std::exception& ex) {
689707
Log(LogCritical, "cli") << "Exception in main process: " << DiagnosticInformation(ex);
708+
throw;
690709
return EXIT_FAILURE;
691710
} catch (...) {
711+
throw;
692712
return EXIT_FAILURE;
693713
}
694714
#else /* _WIN32 */

0 commit comments

Comments
 (0)