Skip to content

Commit

Permalink
feat(ActionHandler): log errors when invoking action failed (#1205)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverschwendener authored Sep 13, 2024
1 parent a6bba02 commit 5347207
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/main/Core/ActionHandler/ActionHandlerModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ export class ActionHandlerModule {
public static bootstrap(dependencyRegistry: DependencyRegistry<Dependencies>) {
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);
}
});
}
}
4 changes: 2 additions & 2 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5347207

Please sign in to comment.