X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcharging-station%2FBootstrap.ts;h=7c80067ccd93905b2e76cec7ac9a3641bd670ff6;hb=36999e7745b090d38c68015929b5d223b4162613;hp=eb437ab08cf5e6e81baa1e8bf69499133200e456;hpb=ba7965c4b933e479b36fc81f934a643336efcbea;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index eb437ab0..7c80067c 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -18,7 +18,7 @@ import { ChargingStationWorkerMessageEvents, } from '../types/ChargingStationWorker'; import type { StationTemplateUrl } from '../types/ConfigurationData'; -import type Statistics from '../types/Statistics'; +import type { Statistics } from '../types/Statistics'; import Configuration from '../utils/Configuration'; import logger from '../utils/Logger'; import Utils from '../utils/Utils'; @@ -75,6 +75,9 @@ export class Bootstrap { public async start(): Promise { if (isMainThread && this.started === false) { try { + // Enable unconditionally for now + this.logUnhandledRejection(); + this.logUncaughtException(); this.initialize(); await this.storage?.open(); await this.workerImplementation.start(); @@ -244,6 +247,18 @@ export class Bootstrap { this.initializeWorkerImplementation(); } + private logUncaughtException(): void { + process.on('uncaughtException', (error: Error) => { + console.error(chalk.red('Uncaught exception: '), error); + }); + } + + private logUnhandledRejection(): void { + process.on('unhandledRejection', (reason: unknown) => { + console.error(chalk.red('Unhandled rejection: '), reason); + }); + } + private async startChargingStation( index: number, stationTemplateUrl: StationTemplateUrl