Skip to content

Latest commit

 

History

History
52 lines (39 loc) · 1.02 KB

node-execute-block-wrong-error-thrown.md

File metadata and controls

52 lines (39 loc) · 1.02 KB

node-execute-block-wrong-error-thrown

The execute() method in a node may only throw ApplicationError, NodeApiError, NodeOperationError, or TriggerCloseError`.

📋 This rule is part of the plugin:n8n-nodes-base/nodes config.

Examples

❌ Example of incorrect code:

class TestNode {
	execute() {
		throw new Error("An error occurred");
	}
}

✅ Example of correct code:

class TestNode {
	execute() {
		throw new NodeApiError(this.getNode(), "An error occurred");
	}
}

class TestNode {
	execute() {
		throw new NodeOperationError(this.getNode(), "An error occurred");
	}
}

class TestNode {
	execute() {
		throw new ApplicationError("An error occurred", { level: "warning" });
	}
}

class TestNode {
	execute() {
		throw new TriggerCloseError(this.getNode());
	}
}

Links