Skip to content

Commit

Permalink
Pretty output
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Jun 19, 2023
1 parent 6b43bfe commit eaf9e2f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/PrettierWorkerInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export class PrettierWorkerInstance {
this.callMethodResolvers.delete(payload.id);
if (resolver) {
if (payload.isError) {
resolver.reject(payload.result);
resolver.reject(
Object.assign(payload.result.error, payload.result.errorObj)
);
} else {
resolver.resolve(payload.result);
}
Expand Down
12 changes: 4 additions & 8 deletions src/worker/prettier-instance-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ function requireInstance(modulePath) {
}

function serializeError(errorObj) {
if (errorObj instanceof Error) {
return {
name: errorObj.name,
message: errorObj.message,
stack: errorObj.stack,
};
}
return errorObj;
return {
error: errorObj,
errorData: { ...errorObj },
};
}

parentPort.on("message", ({ type, payload }) => {
Expand Down

0 comments on commit eaf9e2f

Please sign in to comment.