Skip to content

Commit

Permalink
fix: Fix to catch error (#82) (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikuroXina authored Mar 22, 2022
1 parent 8c466fc commit d60a93b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
16 changes: 12 additions & 4 deletions src/runner/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ export class MessageResponseRunner<
}

private async triggerEvent(event: MessageEvent, message: M): Promise<void> {
await Promise.all(this.responders.map((res) => res.on(event, message)));
try {
await Promise.all(this.responders.map((res) => res.on(event, message)));
} catch (e) {
console.error(e);
}
}

private responders: R[] = [];
Expand Down Expand Up @@ -109,9 +113,13 @@ export class MessageUpdateResponseRunner<M> {
}

private async triggerEvent([before, after]: [M, M]): Promise<void> {
await Promise.all(
this.responders.map((res) => res.on('UPDATE', before, after))
);
try {
await Promise.all(
this.responders.map((res) => res.on('UPDATE', before, after))
);
} catch (e) {
console.error(e);
}
}

private responders: MessageUpdateEventResponder<M>[] = [];
Expand Down
6 changes: 5 additions & 1 deletion src/runner/role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ export const composeRoleEventResponders = <R>(

export class RoleResponseRunner<R> {
async triggerEvent(event: RoleEvent, role: R): Promise<void> {
await Promise.all(this.responder.map((res) => res.on(event, role)));
try {
await Promise.all(this.responder.map((res) => res.on(event, role)));
} catch (e) {
console.error(e);
}
}

private responder: RoleEventResponder<R>[] = [];
Expand Down
5 changes: 4 additions & 1 deletion src/runner/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ export class ScheduleRunner {
}
const id = setTimeout(() => {
void (async () => {
const newTimeout = await task();
const newTimeout = await task().catch((e) => {
console.error(e);
return null;
});
this.onDidRun(key, task, newTimeout);
})();
}, differenceInMilliseconds(timeout, this.clock.now()));
Expand Down
8 changes: 7 additions & 1 deletion src/runner/voice-room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ export class VoiceRoomResponseRunner<V> {
event: VoiceRoomEvent,
voiceState: V
): Promise<void> {
await Promise.all(this.responders.map((res) => res.on(event, voiceState)));
try {
await Promise.all(
this.responders.map((res) => res.on(event, voiceState))
);
} catch (e) {
console.error(e);
}
}

private responders: VoiceRoomEventResponder<V>[] = [];
Expand Down

0 comments on commit d60a93b

Please sign in to comment.