The execute()
method in a node may only throw NodeApiError
for failed API requests and NodeOperationError
for internal errors, not the built-in Error
. Refer to NodeErrors.ts
.
📋 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");
}
}