Skip to content

Commit

Permalink
core: uncaught error handler made easily overridable (eclipse-theia#1…
Browse files Browse the repository at this point in the history
…2068)

Signed-off-by: Federico Bozzini <[email protected]>
  • Loading branch information
federicobozzini authored and erezmus committed Aug 2, 2023
1 parent 530729f commit 9a91ee0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/core/src/node/backend-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,7 @@ export class BackendApplication {
protected readonly contributionsProvider: ContributionProvider<BackendApplicationContribution>,
@inject(BackendApplicationCliContribution) protected readonly cliParams: BackendApplicationCliContribution) {
process.on('uncaughtException', error => {
if (error) {
console.error('Uncaught Exception: ', error.toString());
if (error.stack) {
console.error(error.stack);
}
}
this.handleUncaughtError(error);
});

// Workaround for Electron not installing a handler to ignore SIGPIPE error
Expand Down Expand Up @@ -335,4 +330,13 @@ export class BackendApplication {
return this.stopwatch.startAsync(name, `Backend ${name}`, fn, { thresholdMillis: TIMER_WARNING_THRESHOLD });
}

protected handleUncaughtError(error: Error): void {
if (error) {
console.error('Uncaught Exception: ', error.toString());
if (error.stack) {
console.error(error.stack);
}
}
}

}

0 comments on commit 9a91ee0

Please sign in to comment.