X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fworker%2Fabstract-worker.ts;h=cd8f2346365f20ca5fb9e029dd436113594f19ac;hb=68f1f53125a7fd7744a6a847bc8e19c8da375892;hp=5b3c3a3f06596b00fad84e691875b438325bc600;hpb=edd5088275648b8ae534dcd75ba23443fe947954;p=poolifier.git diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 5b3c3a3f..cd8f2346 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -460,11 +460,11 @@ export abstract class AbstractWorker< /** * Handles an error and convert it to a string so it can be sent back to the main worker. * - * @param e - The error raised by the worker. + * @param error - The error raised by the worker. * @returns The error message. */ - protected handleError (e: Error | string): string { - return e instanceof Error ? e.message : e + protected handleError (error: Error | string): string { + return error instanceof Error ? error.message : error } /** @@ -516,12 +516,11 @@ export abstract class AbstractWorker< workerId: this.id, taskId }) - } catch (e) { - const errorMessage = this.handleError(e as Error | string) + } catch (error) { this.sendToMainWorker({ taskError: { name: name as string, - message: errorMessage, + message: this.handleError(error as Error | string), data }, workerId: this.id, @@ -555,12 +554,11 @@ export abstract class AbstractWorker< }) return null }) - .catch(e => { - const errorMessage = this.handleError(e as Error | string) + .catch(error => { this.sendToMainWorker({ taskError: { name: name as string, - message: errorMessage, + message: this.handleError(error as Error | string), data }, workerId: this.id,