Skip to content

Commit

Permalink
move the check earlier in the constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy committed Jan 16, 2024
1 parent 8fc7385 commit 4931730
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions packages/workflow/src/errors/abstract/node.error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@ const COMMON_ERRORS: IDataObject = {
* a value recursively inside an error object.
*/
export abstract class NodeError extends ExecutionBaseError {
node: INode;

constructor(node: INode, error: Error | JsonObject) {
if (error instanceof Error) {
super(error.message, { cause: error });
} else {
super('', { errorResponse: error });
}

this.node = node;

constructor(
readonly node: INode,
error: Error | JsonObject,
) {
if (error instanceof NodeError) return error;

const isError = error instanceof Error;
const message = isError ? error.message : '';
const options = isError ? { cause: error } : { errorResponse: error };
super(message, options);
}

/**
Expand Down

0 comments on commit 4931730

Please sign in to comment.