X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2FWorkerAbstract.ts;h=0fccdb812d7ed4c2a40b28596a3cfc883ed606e3;hb=293aaa3118bbd8c6a6e7933f049d51031c134fa6;hp=bfb7933639eb1e3445e6bd71cafeef12807f2b3e;hpb=3fa0f0edb5e3bb9fff2b343fb4ad7fc6c7c8df34;p=e-mobility-charging-stations-simulator.git diff --git a/src/worker/WorkerAbstract.ts b/src/worker/WorkerAbstract.ts index bfb79336..0fccdb81 100644 --- a/src/worker/WorkerAbstract.ts +++ b/src/worker/WorkerAbstract.ts @@ -1,6 +1,7 @@ -import { WorkerData, WorkerOptions } from '../types/Worker'; +import fs from 'fs'; import WorkerConstants from './WorkerConstants'; +import type { WorkerData, WorkerOptions } from '../types/Worker'; export default abstract class WorkerAbstract { protected readonly workerScript: string; @@ -11,8 +12,8 @@ export default abstract class WorkerAbstract { /** * `WorkerAbstract` constructor. * - * @param workerScript - * @param workerOptions + * @param workerScript - + * @param workerOptions - */ constructor( workerScript: string, @@ -28,6 +29,12 @@ export default abstract class WorkerAbstract { }, } ) { + if (!workerScript) { + throw new Error('Worker script is not defined'); + } + if (!fs.existsSync(workerScript)) { + throw new Error('Worker script file does not exist'); + } this.workerScript = workerScript; this.workerOptions = workerOptions; }