Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
'Cannot instantiate a pool without specifying the number of workers'
)
} else if (Number.isSafeInteger(numberOfWorkers) === false) {
- throw new Error(
+ throw new TypeError(
'Cannot instantiate a pool with a non integer number of workers'
)
} else if (numberOfWorkers < 0) {
- throw new Error(
+ throw new RangeError(
'Cannot instantiate a pool with a negative number of workers'
)
} else if (this.type === PoolType.FIXED && numberOfWorkers === 0) {
this.opts.killBehavior = opts.killBehavior ?? DEFAULT_KILL_BEHAVIOR
this.opts.maxInactiveTime =
opts.maxInactiveTime ?? DEFAULT_MAX_INACTIVE_TIME
- /**
- * Whether the worker is working asynchronously or not.
- */
this.opts.async = !!opts.async
}
() =>
new FixedClusterPool(-1, './tests/worker-files/cluster/testWorker.js')
).toThrowError(
- new Error('Cannot instantiate a pool with a negative number of workers')
+ new RangeError(
+ 'Cannot instantiate a pool with a negative number of workers'
+ )
)
})
() =>
new FixedThreadPool(0.25, './tests/worker-files/thread/testWorker.js')
).toThrowError(
- new Error(
+ new TypeError(
'Cannot instantiate a pool with a non integer number of workers'
)
)