From: Jérôme Benoit Date: Sat, 16 Sep 2023 21:58:38 +0000 (+0200) Subject: refactor: code cleanup X-Git-Tag: v2.6.45~6 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=646bced2dd1695fbb7c8595f37b4713f44b03fb0;p=poolifier.git refactor: code cleanup Signed-off-by: Jérôme Benoit --- 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, diff --git a/src/worker/thread-worker.ts b/src/worker/thread-worker.ts index 8d30ef21..d6a36992 100644 --- a/src/worker/thread-worker.ts +++ b/src/worker/thread-worker.ts @@ -93,7 +93,7 @@ export class ThreadWorker< } /** @inheritDoc */ - protected handleError (e: Error | string): string { - return e as string + protected handleError (error: Error | string): string { + return error as string } }