{"record":{"id":"8d36c04cd64b6b49","repo":"n8n-io/n8n","slug":"error-message-8d36c0","errorCode":null,"errorMessage":"${error.message}","messagePattern":"\\$\\{error\\.message\\}","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v1/actions/router.ts","lineNumber":80,"sourceCode":"\n\t\t\tif (error instanceof NodeApiError) {\n\t\t\t\t// If the error is a rate limit error, we want to handle it differently\n\t\t\t\tconst errorCode: string | undefined = (error.cause as any)?.error?.error?.code;\n\t\t\t\tif (errorCode) {\n\t\t\t\t\tconst customErrorMessage = getCustomErrorMessage(errorCode);\n\t\t\t\t\tif (customErrorMessage) {\n\t\t\t\t\t\terror.message = customErrorMessage;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\terror.context = {\n\t\t\t\t\titemIndex: i,\n\t\t\t\t};\n\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tthrow new NodeOperationError(this.getNode(), error, {\n\t\t\t\titemIndex: i,\n\t\t\t\tdescription: error.description,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn [returnData];\n}\n","sourceCodeStart":62,"sourceCodeEnd":89,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v1/actions/router.ts#L62-L89","documentation":"The v1 router's main execution loop catches errors from individual item processing. If the error is not a NodeApiError (which gets custom message handling), and continueOnFail is not enabled, the error is wrapped in a NodeOperationError with itemIndex context and the original description. This is the catch-all error wrapper ensuring every failure carries item-level context. For non-Error throws (e.g. a string or plain object), passing error directly to NodeOperationError may produce unexpected message formatting.","triggerScenarios":"Any error thrown by a sub-operation (assistant, audio, file, image, text) that is not a NodeApiError and continueOnFail is not enabled. The catch block wraps it with itemIndex. If the thrown value is not a standard Error instance, passing it as the message to NodeOperationError can produce '[object Object]' or similar.","commonSituations":"A sub-operation throws a plain Error or a non-Error value; a third-party library error bubbles up through the operation; assertion failures in the sub-operation logic.","solutions":["Inspect the error.description and error.message fields — the original error is preserved as the cause/message","Enable 'Continue On Fail' in the node settings to collect all errors without stopping execution","Identify which item (itemIndex in error.context) triggered the failure and inspect that specific input item"],"exampleFix":"// Enable 'Continue On Fail' to collect errors instead of stopping:\n// In node settings → Settings tab → toggle 'Continue On Fail'","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Enable continueOnFail to handle errors per-item\ntry {\n  const result = await execute.call(this, i);\n  returnData.push(...result);\n} catch (error) {\n  if (this.continueOnFail()) {\n    returnData.push({ json: { error: error.message }, pairedItem: { item: i } });\n    continue;\n  }\n  if (error instanceof NodeApiError) throw error;\n  throw new NodeOperationError(this.getNode(), error, { itemIndex: i });\n}","preventionTips":["Enable 'Continue On Fail' in node settings to collect errors without stopping","Inspect error.context.itemIndex to identify which input item failed","Validate input data before this node to reduce sub-operation failures"],"tags":["openai","router","error-wrapper","catch-all","v1"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}