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.
❌ 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());
}
}