public async start(): Promise<void> {
if (isMainThread && this.started === false) {
try {
+ // Enable unconditionally for now
+ this.logUnhandledRejection();
+ this.logUncaughtException();
this.initialize();
await this.storage?.open();
await this.workerImplementation.start();
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
} else {
// Add message listener to start charging station from main thread
addMessageListener();
- if (!Utils.isUndefined(workerData)) {
+ if (Utils.isUndefined(workerData) === false) {
startChargingStation(workerData as ChargingStationWorkerData);
}
}