X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2FWorkerAbstract.ts;h=1dd064fbf893023ed4f41b91c411f298de1cd1b1;hb=793e927700cd3841dd6373677cd699795a4f187f;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..1dd064fb 100644 --- a/src/worker/WorkerAbstract.ts +++ b/src/worker/WorkerAbstract.ts @@ -1,6 +1,7 @@ import { WorkerData, WorkerOptions } from '../types/Worker'; import WorkerConstants from './WorkerConstants'; +import fs from 'fs'; export default abstract class WorkerAbstract { protected readonly 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; }