new Function(`return ${taskFunction as string}`)() as TaskFunction<
Data,
Response
- > /* NOSONAR */
+ >
)
} else if (taskFunctionOperation === 'remove') {
response = this.removeTaskFunction(taskFunctionName as string)
this.sendToMainWorker({
taskFunctionOperation,
taskFunctionOperationStatus: response.status,
- workerError: {
- name: taskFunctionName as string,
- message: this.handleError(response.error as Error | string)
- }
+ taskFunctionName,
+ ...(!response.status &&
+ response?.error != null && {
+ workerError: {
+ name: taskFunctionName as string,
+ message: this.handleError(response.error as Error | string)
+ }
+ })
})
}