diff --git a/Core/App/app.cpp b/Core/App/app.cpp index 4a96a09..3a0f079 100644 --- a/Core/App/app.cpp +++ b/Core/App/app.cpp @@ -1,5 +1,6 @@ #include "Helper/delay_helper.h" #include "stm32h563xx.h" +#include #include "Center/common_center.hpp" #include "Common/serial_port.hpp" @@ -8,8 +9,24 @@ void TerminateHandler() { - auto led = Config::kLed; + auto led = Config::kLed; + auto& debugSerialPort = CommonCenter::GetDebugSerialPort(); + std::string message; + std::exception_ptr exceptionPtr = std::current_exception(); + if (exceptionPtr) { + try { + std::rethrow_exception(exceptionPtr); + } catch (const std::exception& e) { + message = e.what(); + } catch (...) { + message = "Unknown exception type"; + } + } else { + message = "No active exception, but terminate() was called"; + } + while (true) { + debugSerialPort.WriteLineBlocking("FATAL ERROR: %s", message.c_str()); led.Toggle(); DelayS(1); } @@ -31,6 +48,7 @@ void Setup() { GpioSetup(); DelaySetup(); CommonSetup(); + std::set_terminate(TerminateHandler); } extern "C" void AppStart() {