// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`Task function operation '${message.taskFunctionOperation?.toString()}' failed on worker ${message.workerId?.toString()} with error: '${
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
- message.workerError?.error?.message ??
message.workerError?.message
}'`
)
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
}' failed on worker ${errorResponse?.workerId?.toString()} with error: '${
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
- errorResponse?.workerError?.error?.message ??
errorResponse?.workerError?.message
}'`
)
/**
* Error message.
*/
- readonly message?: string
+ readonly message: string
/**
* Task function name triggering the error.
*/
*/
protected abstract handleError (error: Error): {
error?: Error
- message?: string
+ message: string
stack?: string
}
/**
* @inheritDoc
*/
- protected handleError (error: Error): { error: Error } {
- return { error }
+ protected handleError (error: Error): {
+ error: Error
+ message: string
+ stack?: string
+ } {
+ return { error, message: error.message, stack: error.stack }
}
/** @inheritDoc */
expect(typeof inError.stack === 'string').toBe(true)
expect(taskError).toStrictEqual({
data,
- message: 'Error Message from ClusterWorker',
+ message: inError.message,
name: DEFAULT_TASK_NAME,
- stack: expect.any(String),
+ stack: inError.stack,
})
expect(
errorPool.workerNodes.some(
expect(typeof inError.stack === 'string').toBe(true)
expect(taskError).toStrictEqual({
data,
- message: 'Error Message from ClusterWorker:async',
+ message: inError.message,
name: DEFAULT_TASK_NAME,
- stack: expect.any(String),
+ stack: inError.stack,
})
expect(
asyncErrorPool.workerNodes.some(
}
expect(inError).toBeInstanceOf(Error)
expect(inError.message).toStrictEqual('Error Message from ThreadWorker')
+ expect(typeof inError.stack === 'string').toBe(true)
expect(taskError).toStrictEqual({
data,
- error: new Error('Error Message from ThreadWorker'),
+ error: inError,
+ message: inError.message,
name: DEFAULT_TASK_NAME,
+ stack: inError.stack,
})
expect(
errorPool.workerNodes.some(
expect(inError.message).toStrictEqual(
'Error Message from ThreadWorker:async'
)
+ expect(typeof inError.stack === 'string').toBe(true)
expect(taskError).toStrictEqual({
data,
- error: new Error('Error Message from ThreadWorker:async'),
+ error: inError,
+ message: inError.message,
name: DEFAULT_TASK_NAME,
+ stack: inError.stack,
})
expect(
asyncErrorPool.workerNodes.some(
it('Verify that handleError() method is working properly', () => {
const error = new Error('Error as an error')
const worker = new ThreadWorker(() => {})
- expect(worker.handleError(error)).toStrictEqual({ error })
+ expect(worker.handleError(error)).toStrictEqual({
+ error,
+ message: error.message,
+ stack: error.stack,
+ })
})
it('Verify that sendToMainWorker() method invokes the port property postMessage() method', () => {