Skip to content

Commit

Permalink
feat: emit client errors when gateway event fails
Browse files Browse the repository at this point in the history
  • Loading branch information
DjDeveloperr committed Sep 18, 2021
1 parent 809117a commit 77f7975
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/gateway/handlers/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ export type ClientEvents = {
commandUsed: [ctx: CommandContext]
commandError: [ctx: CommandContext, err: Error]
gatewayError: [err: ErrorEvent, shards: [number, number]]
error: [error: Error]

threadCreate: [thread: ThreadChannel]
threadDelete: [thread: ThreadChannel]
Expand Down
4 changes: 2 additions & 2 deletions src/gateway/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ export class Gateway extends HarmonyEventEmitter<GatewayTypedEvents> {

if (handler !== undefined && d !== null) {
try {
handler(this, d)
await handler(this, d)
} catch (e) {
console.error(`Internal error in Shard ${this.shardID}: ${e}`)
this.client.emit('error', e)
}
}
}
Expand Down

0 comments on commit 77f7975

Please sign in to comment.