Skip to content

Commit

Permalink
prevent infinity loop on logging unhandled error (#2147)
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrik authored Apr 4, 2023
1 parent 7f3dd27 commit 19271d1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/errors/unhandledErrorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@ export class UnhandledErrorHandler {
}

public handlerError(event: ErrorEvent): void {
this.logger.trackError(event.error);
try {
this.logger.trackError(event.error);
} catch (error) {
console.error(`Unable to log event.error: ${event.error} - Error:`, error);
}
}

public handlerPromiseRejection(event: PromiseRejectionEvent): void {
this.logger.trackError(event.reason);
try {
this.logger.trackError(event.reason);
} catch (error) {
console.error(`Unable to log Promise Rejection event.reason: ${event.reason} - Error:`, error);
}
}
}

0 comments on commit 19271d1

Please sign in to comment.