openblocks/core/src/panic.cpp

29 lines
No EOL
614 B
C++

#include "panic.h"
#include <cstdlib>
#include "logger.h"
#include "platform.h"
#ifdef _NDEBUG
#define NDEBUG
#endif
bool trySafeAbort = false;
void panic() {
// We've already been here, safe aborting has failed.
if (trySafeAbort)
abort();
trySafeAbort = true;
#ifndef NDEBUG
displayErrorMessage(std::string("A fatal error has occurred and Openblocks had to shut down.\n\
The currently open document will be attempted to be saved, and logs will be written to " + getProgramLogsDir()));
#endif
// Finalize logger
Logger::finish();
// TODO: Autosave document
abort();
}