Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit a5a8e16

Browse files
committed
refactor(workers): minor refactor to fix issue with BuildError.toJson not working correctly
1 parent 7f1e54c commit a5a8e16

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/worker-process.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { BuildError } from './util/errors';
2+
import { buildErrorToJson } from './util/helpers';
23
import { Logger } from './logger/logger';
34
import { WorkerMessage } from './util/interfaces';
45

@@ -39,11 +40,13 @@ function taskResolve(taskModule: string, taskWorker: string, val: any) {
3940
}
4041

4142

42-
function taskReject(taskModule: string, taskWorker: string, val: any) {
43+
function taskReject(taskModule: string, taskWorker: string, error: Error) {
44+
const buildError = new BuildError(error.message);
45+
const json = buildErrorToJson(buildError);
4346
const msg: WorkerMessage = {
4447
taskModule: taskModule,
4548
taskWorker: taskWorker,
46-
reject: new BuildError(val).toJson(),
49+
reject: json,
4750
pid: process.pid
4851
};
4952

@@ -53,11 +56,13 @@ function taskReject(taskModule: string, taskWorker: string, val: any) {
5356
}
5457

5558

56-
function taskError(taskModule: string, taskWorker: string, err: any) {
59+
function taskError(taskModule: string, taskWorker: string, error: Error) {
60+
const buildError = new BuildError(error.message);
61+
const json = buildErrorToJson(buildError);
5762
const msg: WorkerMessage = {
5863
taskModule: taskModule,
5964
taskWorker: taskWorker,
60-
error: new BuildError(err).toJson(),
65+
error: json,
6166
pid: process.pid
6267
};
6368

0 commit comments

Comments
 (0)