From 53472073ee055746fca603b11ee889f79af73873 Mon Sep 17 00:00:00 2001 From: Oliver Schwendener Date: Fri, 13 Sep 2024 18:02:00 +0200 Subject: [PATCH] feat(ActionHandler): log errors when invoking action failed (#1205) --- src/main/Core/ActionHandler/ActionHandlerModule.ts | 11 +++++++++-- src/main/index.ts | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/Core/ActionHandler/ActionHandlerModule.ts b/src/main/Core/ActionHandler/ActionHandlerModule.ts index 21e0d6d4b..ec8181b7a 100644 --- a/src/main/Core/ActionHandler/ActionHandlerModule.ts +++ b/src/main/Core/ActionHandler/ActionHandlerModule.ts @@ -7,14 +7,21 @@ export class ActionHandlerModule { public static bootstrap(dependencyRegistry: DependencyRegistry) { const eventEmitter = dependencyRegistry.get("EventEmitter"); const ipcMain = dependencyRegistry.get("IpcMain"); + const logger = dependencyRegistry.get("Logger"); const actionHandlerRegistry = new ActionHandlerRegistry(); dependencyRegistry.register("ActionHandlerRegistry", actionHandlerRegistry); ipcMain.handle("invokeAction", async (_, { action }: { action: SearchResultItemAction }) => { - await actionHandlerRegistry.getById(action.handlerId).invokeAction(action); - eventEmitter.emitEvent("actionInvoked", { action }); + try { + await actionHandlerRegistry.getById(action.handlerId).invokeAction(action); + eventEmitter.emitEvent("actionInvoked", { action }); + } catch (error) { + const errorMessage = `Error while invoking action: ${error}`; + logger.error(errorMessage); + return Promise.reject(errorMessage); + } }); } } diff --git a/src/main/index.ts b/src/main/index.ts index 60f72c03f..3202f36e4 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -38,15 +38,15 @@ import * as Extensions from "./Extensions"; Core.EventEmitterModule.bootstrap(dependencyRegistry); Core.EventSubscriberModule.bootstrap(dependencyRegistry); Core.BrowserWindowNotifierModule.bootstrap(dependencyRegistry); + Core.DateProviderModule.bootstrap(dependencyRegistry); + Core.LoggerModule.bootstrap(dependencyRegistry); Core.ActionHandlerModule.bootstrap(dependencyRegistry); Core.RandomStringProviderModule.bootstrap(dependencyRegistry); Core.SafeStorageEncryptionModule.bootstrap(dependencyRegistry); Core.AssetPathResolverModule.bootstrap(dependencyRegistry); Core.ShellModule.bootstrap(dependencyRegistry); Core.ClipboardModule.bootstrap(dependencyRegistry); - Core.DateProviderModule.bootstrap(dependencyRegistry); Core.AboutUeliModule.bootstrap(dependencyRegistry); - Core.LoggerModule.bootstrap(dependencyRegistry); Core.CommandlineUtilityModule.bootstrap(dependencyRegistry); Core.AppleScriptUtilityModule.bootstrap(dependencyRegistry); Core.FileSystemUtilityModule.bootstrap(dependencyRegistry);