From ef5df3020398a5b0de88797cacfc46c27211ff04 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Mon, 3 Jun 2024 13:42:58 +0800 Subject: [PATCH] Handle error in a graceful way --- Build/index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Build/index.ts b/Build/index.ts index d5b523fe..fd22e511 100644 --- a/Build/index.ts +++ b/Build/index.ts @@ -28,6 +28,15 @@ import { buildCloudMounterRules } from './build-cloudmounter-rules'; import { createSpan, printTraceResult } from './trace'; import { buildDeprecateFiles } from './build-deprecate-files'; +process.on('uncaughtException', (error) => { + console.error('Uncaught exception:', error); + process.exit(1); +}); +process.on('unhandledRejection', (reason) => { + console.error('Unhandled rejection:', reason); + process.exit(1); +}); + (async () => { const rootSpan = createSpan('root');