Skip to content

Commit

Permalink
Wrap async execute inside try block
Browse files Browse the repository at this point in the history
We converted execute method to asynchronous from synchronous
and this commit wraps the usage of that async method inside try
block to avoid errors
  • Loading branch information
sudeeptarlekar authored and DmitryAstafyev committed Mar 1, 2024
1 parent 78fa3ea commit 23da4e8
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions application/holder/src/service/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,19 @@ export class Service extends Implementation {

protected async check(): Promise<void> {
const actions = getActions();
const runner = async (actions: Actions.CLIAction[]): Promise<void> => {
for (const action of actions) {
await action.execute(this);
}
};
await runner(actions.filter((a) => a.type() === Actions.Type.StateModifier));
await runner(actions.filter((a) => a.type() === Actions.Type.Action));
await runner(actions.filter((a) => a.type() === Actions.Type.AfterActions));
Events.IpcEvent.emit(new Events.Cli.Done.Event());
try {
const runner = async (actions: Actions.CLIAction[]): Promise<void> => {
for (const action of actions) {
await action.execute(this);
}
};
await runner(actions.filter((a) => a.type() === Actions.Type.StateModifier));
await runner(actions.filter((a) => a.type() === Actions.Type.Action));
await runner(actions.filter((a) => a.type() === Actions.Type.AfterActions));
Events.IpcEvent.emit(new Events.Cli.Done.Event());
} catch (e) {
return Promise.reject(e);
}
}
}
export interface Service extends Interface {}
Expand Down

0 comments on commit 23da4e8

Please sign in to comment.