MCPcopy Create free account
hub / github.com/couchbase/fleece / installTerminateHandler

Method installTerminateHandler

Fleece/Support/Backtrace.cc:344–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342
343
344 void Backtrace::installTerminateHandler(function<void(const string&)> logger) {
345 static once_flag sOnce;
346 call_once(sOnce, [&] {
347 static auto const sLogger = move(logger);
348 static terminate_handler const sOldHandler = set_terminate([] {
349 // ---- Code below gets called by C++ runtime on an uncaught exception ---
350 if (sLogger) {
351 stringstream out;
352 writeCrashLog(out);
353 sLogger(out.str());
354 } else {
355 cerr << "\n\n******************** C++ fatal error ********************\n";
356 writeCrashLog(cerr);
357 cerr << "\n******************** Now terminating ********************\n";
358 }
359 // Chain to old handler:
360 sOldHandler();
361 // Just in case the old handler doesn't abort:
362 abort();
363 // ---- End of handler ----
364 });
365 });
366 }
367
368}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected