Standardize error handling patterns and improve ErrorHandler integration.
- Added a comprehensive error propagation standardization report detailing dominant patterns, inconsistencies, and recommended remediations (`docs/audits/error-propagation-standardization.md`). - Integrated `ErrorHandler` into key components, including `main.cc` for robust exception reporting, and added centralized logging to a user state path. - Introduced EINTR-safe syscall wrappers (`SyscallWrappers.h`, `.cc`) to improve resilience of file and metadata operations. - Enhanced `DEVELOPER_GUIDE.md` with an error handling conventions section, covering pattern guidelines and best practices. - Identified gaps in `PieceTable` and internal helpers; deferred fixes with detailed recommendations for improved memory allocation error reporting.
This commit is contained in:
6
main.cc
6
main.cc
@@ -20,6 +20,7 @@
|
||||
#include "Editor.h"
|
||||
#include "Frontend.h"
|
||||
#include "TerminalFrontend.h"
|
||||
#include "ErrorHandler.h"
|
||||
|
||||
#if defined(KTE_BUILD_GUI)
|
||||
#if defined(KTE_USE_QT)
|
||||
@@ -199,6 +200,8 @@ main(int argc, char *argv[])
|
||||
use_gui = false;
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
// Default depends on build target: kge defaults to GUI, kte to terminal
|
||||
#if defined(KTE_DEFAULT_GUI)
|
||||
use_gui = true;
|
||||
@@ -306,11 +309,14 @@ main(int argc, char *argv[])
|
||||
|
||||
return 0;
|
||||
} catch (const std::exception &e) {
|
||||
std::string msg = std::string("Unhandled exception: ") + e.what();
|
||||
kte::ErrorHandler::Instance().Critical("main", msg);
|
||||
std::cerr << "\n*** FATAL ERROR ***\n"
|
||||
<< "kte encountered an unhandled exception: " << e.what() << "\n"
|
||||
<< "The editor will now exit. Any unsaved changes may be recovered from swap files.\n";
|
||||
return 1;
|
||||
} catch (...) {
|
||||
kte::ErrorHandler::Instance().Critical("main", "Unknown exception");
|
||||
std::cerr << "\n*** FATAL ERROR ***\n"
|
||||
<< "kte encountered an unknown exception.\n"
|
||||
<< "The editor will now exit. Any unsaved changes may be recovered from swap files.\n";
|
||||
|
||||
Reference in New Issue
Block a user