Skip to content

Latest commit

 

History

History
40 lines (29 loc) · 994 Bytes

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

File metadata and controls

40 lines (29 loc) · 994 Bytes

node-execute-block-wrong-error-thrown

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.

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");
	}
}

Links