I am trying to figure out how to throw an error message and continue in a code node so that I can include it in a summary email of errors. My other nodes have errors n8n can handle, but I need to be able to throw custom ones. I tried too many methods to list lol!
I have written an example of what I am trying to do. The code node for the done path of the loop includes the errors from the requests, but I would like mine from Code2 there as well. I tried reading the code node after the loop was done, but it only returns the last result.
Version: 1.77.3
Output
[{“error”: {“message”: “connect ECONNREFUSED 127.0.0.1:443”,“name”: “Error”,“stack”: “Error: connect ECONNREFUSED 127.0.0.1:443\n at Function.AxiosError.from (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/AxiosError.js:89:14)\n at RedirectableRequest.handleRequestError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:620:25)\n at RedirectableRequest.emit (node:events:530:35)\n at ClientRequest.eventHandlers. (/usr/local/lib/node_modules/n8n/node_modules/follow-redirects/index.js:49:24)\n at ClientRequest.emit (node:events:518:28)\n at emitErrorEvent (node:_http_client:101:11)\n at TLSSocket.socketErrorListener (node:_http_client:504:5)\n at TLSSocket.emit (node:events:518:28)\n at emitErrorNT (node:internal/streams/destroy:169:8)\n at emitErrorCloseNT (node:internal/streams/destroy:128:3)\n at Axios.request (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/Axios.js:45:41)\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at invokeAxios (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/node-execute-functions.js:583:16)\n at proxyRequestToAxios (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/node-execute-functions.js:612:26)\n at Object.request (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/node-execute-functions.js:1478:50)”,“code”: “ECONNREFUSED”,“status”: null}},{“error”: {“message”: “connect ECONNREFUSED 127.0.0.1:443”,“name”: “Error”,“stack”: “Error: connect ECONNREFUSED 127.0.0.1:443\n at Function.AxiosError.from (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/AxiosError.js:89:14)\n at RedirectableRequest.handleRequestError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:620:25)\n at RedirectableRequest.emit (node:events:530:35)\n at ClientRequest.eventHandlers. (/usr/local/lib/node_modules/n8n/node_modules/follow-redirects/index.js:49:24)\n at ClientRequest.emit (node:events:518:28)\n at emitErrorEvent (node:_http_client:101:11)\n at TLSSocket.socketErrorListener (node:_http_client:504:5)\n at TLSSocket.emit (node:events:518:28)\n at emitErrorNT (node:internal/streams/destroy:169:8)\n at emitErrorCloseNT (node:internal/streams/destroy:128:3)\n at Axios.request (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/Axios.js:45:41)\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at invokeAxios (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/node-execute-functions.js:583:16)\n at proxyRequestToAxios (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/node-execute-functions.js:612:26)\n at Object.request (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/node-execute-functions.js:1478:50)”,“code”: “ECONNREFUSED”,“status”: null}},{“error”: {“message”: “connect ECONNREFUSED 127.0.0.1:443”,“name”: “Error”,“stack”: “Error: connect ECONNREFUSED 127.0.0.1:443\n at Function.AxiosError.from (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/AxiosError.js:89:14)\n at RedirectableRequest.handleRequestError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:620:25)\n at RedirectableRequest.emit (node:events:530:35)\n at ClientRequest.eventHandlers. (/usr/local/lib/node_modules/n8n/node_modules/follow-redirects/index.js:49:24)\n at ClientRequest.emit (node:events:518:28)\n at emitErrorEvent (node:_http_client:101:11)\n at TLSSocket.socketErrorListener (node:_http_client:504:5)\n at TLSSocket.emit (node:events:518:28)\n at emitErrorNT (node:internal/streams/destroy:169:8)\n at emitErrorCloseNT (node:internal/streams/destroy:128:3)\n at Axios.request (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/Axios.js:45:41)\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at invokeAxios (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/node-execute-functions.js:583:16)\n at proxyRequestToAxios (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/node-execute-functions.js:612:26)\n at Object.request (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/node-execute-functions.js:1478:50)”,“code”: “ECONNREFUSED”,“status”: null}}]