Skip to content

Latest commit

 

History

History
98 lines (87 loc) · 1.88 KB

node-execute-block-missing-continue-on-fail.md

File metadata and controls

98 lines (87 loc) · 1.88 KB

node-execute-block-missing-continue-on-fail

The execute() method in a node must implement continueOnFail in a try-catch block.

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

Examples

❌ Example of incorrect code:

class TestNode {
	description = {
		displayName: "Test",
		name: "test",
		icon: "file:test.svg",
		group: ["transform"],
		version: 1,
		subtitle: '={{ $parameter["operation"] + ": " + $parameter["resource"] }}',
		description: "This is a sentence",
		defaults: {
			name: "Test",
		},
		inputs: ["main"],
		outputs: ["main"],
	};
	async execute() {
		for (let i = 0; i < items.length; i++) {
			try {
				// ...
			} catch (error) {
				// ...
			}
		}
	}
}

class TestNode {
	description = {
		displayName: "Test",
		name: "test",
		icon: "file:test.svg",
		group: ["transform"],
		version: 1,
		subtitle: '={{ $parameter["operation"] + ": " + $parameter["resource"] }}',
		description: "This is a sentence",
		defaults: {
			name: "Test",
		},
		inputs: ["main"],
		outputs: ["main"],
	};
	async execute() {
		for (let i = 0; i < items.length; i++) {
			// ...
		}
	}
}

✅ Example of correct code:

class TestNode {
	description = {
		displayName: "Test",
		name: "test",
		icon: "file:test.svg",
		group: ["transform"],
		version: 1,
		subtitle: '={{ $parameter["operation"] + ": " + $parameter["resource"] }}',
		description: "This is a sentence",
		defaults: {
			name: "Test",
		},
		inputs: ["main"],
		outputs: ["main"],
	};
	async execute() {
		for (let i = 0; i < items.length; i++) {
			try {
				// ...
			} catch (error) {
				if (this.continueOnFail()) {
					// ...
				}
			}
		}
	}
}

Links