[//]: # "File generated from a template. Do not edit this file directly." # node-execute-block-wrong-error-thrown The `execute()` method in a node may only throw `NodeOperationError`, `NodeApiError`, `TriggerCloseError`, `UserError`, `OperationalError`, `UnexpectedError`, or the deprecated `ApplicationError`. 📋 This rule is part of the `plugin:n8n-nodes-base/nodes` config. ## Examples ❌ Example of **incorrect** code: ```js class TestNode { execute() { throw new Error("An error occurred"); } } ``` ✅ Example of **correct** code: ```js 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 - [Rule source](../../lib/rules/node-execute-block-wrong-error-thrown.ts) - [Test source](../../tests/node-execute-block-wrong-error-thrown.test.ts)