Skip to content

Commit

Permalink
refactor: refine worker factory arguments checking
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Benoit <[email protected]>
  • Loading branch information
Jérôme Benoit committed Dec 16, 2023
1 parent 27662cf commit 49e2c1e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/worker/WorkerAbstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ export abstract class WorkerAbstract<T extends WorkerData> {
*/
constructor(workerScript: string, workerOptions: WorkerOptions) {
if (workerScript == null) {
throw new Error('Worker script is not defined');
throw new TypeError('Worker script is not defined');
}
if (typeof workerScript === 'string' && workerScript.trim().length === 0) {
throw new Error('Worker script is empty');
if (typeof workerScript !== 'string') {
throw new TypeError('Worker script must be a string');
}
if (workerScript.trim().length === 0) {
throw new Error('Worker script is an empty string');
}
if (!existsSync(workerScript)) {
throw new Error('Worker script file does not exist');
Expand Down

0 comments on commit 49e2c1e

Please sign in to comment.