From 04f4516344e1c6968de6312bcafc8f7e2b3b0eeb Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 14 Aug 2023 16:39:51 +0200 Subject: [PATCH] refactor: refine error message at pool instantiation inside a worker MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/pools/abstract-pool.ts | 4 +++- tests/pools/abstract/abstract-pool.test.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 8332d31a..5633613e 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -106,7 +106,9 @@ export abstract class AbstractPool< protected readonly opts: PoolOptions ) { if (!this.isMain()) { - throw new Error('Cannot start a pool from a worker!') + throw new Error( + 'Cannot start a pool from the same worker type as the current pool one' + ) } this.checkNumberOfWorkers(this.numberOfWorkers) this.checkFilePath(this.filePath) diff --git a/tests/pools/abstract/abstract-pool.test.js b/tests/pools/abstract/abstract-pool.test.js index 953e50d0..86522877 100644 --- a/tests/pools/abstract/abstract-pool.test.js +++ b/tests/pools/abstract/abstract-pool.test.js @@ -33,7 +33,9 @@ describe('Abstract pool test suite', () => { errorHandler: (e) => console.error(e) } ) - ).toThrowError('Cannot start a pool from a worker!') + ).toThrowError( + 'Cannot start a pool from the same worker type as the current pool one' + ) }) it('Verify that filePath is checked', () => { -- 2.34.1