perf(simulator): use content addressable cache for idtag distribution
[e-mobility-charging-stations-simulator.git] / src / worker / WorkerUtils.ts
index a181d80e205a2d6050e0f148311846d9a38db97a..7c72ff3e57fcac90ed51150f7780727a754df808 100644 (file)
@@ -1,9 +1,21 @@
 import chalk from 'chalk';
 
 export class WorkerUtils {
+  private constructor() {
+    // This is intentional
+  }
+
+  public static async sleep(milliSeconds: number): Promise<NodeJS.Timeout> {
+    return new Promise((resolve) => setTimeout(resolve as () => void, milliSeconds));
+  }
+
   public static defaultExitHandler = (code: number): void => {
     if (code !== 0) {
-      console.error(chalk.red(`Worker stopped with exit code ${code}`));
+      console.error(chalk.red(`Worker exited with error exit code: ${code.toString()}`));
     }
   };
+
+  public static defaultErrorHandler = (error: Error): void => {
+    console.error(chalk.red('Worker errored: ', error));
+  };
 }