From 9a91ee02bdc73990cc99fae76be926810a968f17 Mon Sep 17 00:00:00 2001 From: Federico Bozzini Date: Fri, 13 Jan 2023 16:36:39 +0000 Subject: [PATCH] core: uncaught error handler made easily overridable (#12068) Signed-off-by: Federico Bozzini --- packages/core/src/node/backend-application.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/core/src/node/backend-application.ts b/packages/core/src/node/backend-application.ts index 8926a0afd307f..cd8401f652971 100644 --- a/packages/core/src/node/backend-application.ts +++ b/packages/core/src/node/backend-application.ts @@ -159,12 +159,7 @@ export class BackendApplication { protected readonly contributionsProvider: ContributionProvider, @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 @@ -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); + } + } + } + }