fix(startup): improve error handling during app initialization

- Wrapped the service initialization and configuration application in a try-catch block to handle potential errors during startup.
- Added logging for initialization failures to aid in debugging and ensure the main window is created if initialization fails.

This commit enhances the application's resilience by ensuring it can recover from startup errors gracefully.
This commit is contained in:
matt 2026-02-13 01:37:20 +09:00
parent a517a5d96c
commit a406f79209

View file

@ -477,7 +477,7 @@ function createWindow(): void {
*/ */
void app.whenReady().then(() => { void app.whenReady().then(() => {
logger.info('App ready, initializing...'); logger.info('App ready, initializing...');
try {
// Initialize services first // Initialize services first
initializeServices(); initializeServices();
@ -508,6 +508,12 @@ void app.whenReady().then(() => {
mainWindow.focus(); mainWindow.focus();
} }
}); });
} catch (error) {
logger.error('Startup initialization failed:', error);
if (!mainWindow) {
createWindow();
}
}
app.on('activate', () => { app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) { if (BrowserWindow.getAllWindows().length === 0) {