Hello, sometimes when we fetch information to a WF, we encounter an error and want to display it in the console.log of our web app to get an idea where the error is, without having to go to n8n > execution > clicking on the failed attempt > find the failed node > get the error message.
We tried the following JS code in our webapp in the fetch calling to the webhook :
.then((response) => {
if (!response.ok) {
return response.json().then(err => {
console.log("Full error response:", err); // Log the entire error response
const nodeName = err.node || err.nodeName || "Unknown Node"; // Adjust this based on actual error response
const errorMessage = err.message || "Unknown error occurred.";
throw new Error(`Error on node: ${nodeName}\nError message: ${errorMessage}`);
});
}
return response.json();
})
However we only get this as the error object only includes “message” an node information about the node and the actual error
For example, here the information that would have been nice to retrieve in the console.log would have been what we see here (“Node impacted: Send urlGeneretaive3”, error message : ERROR: Bad request - please check your parameters
400 - “{\n "error": {\n "code": 400,\n "message": "Invalid requests[21].updateTextStyle: The textStyle link url: \"\"\n is invalid",\n "status": "INVALID_ARGUMENT"\n }\n}\n” - { “error”: { “code”: 400, “message”: “Invalid requests[21].updateTextStyle: The textStyle link url: ""\n is invalid”, “status”: “INVALID_ARGUMENT” } }"
Is there any way to do so ?
we tried this too :
// .then((response) => {
// if (!response.ok) {
// return response.json().then(err => {
// // Assume the error response contains information about the node, typically in the `node` or `nodeName` field
// const nodeName = err.node || err.nodeName || "Unknown Node";
// const errorMessage = err.message || "Unknown error occurred.";
// throw new Error(`Error on node: ${nodeName}\nError message: ${errorMessage}`);
// });
// }
// return response.json();
But we got : Node : Unknown Node / Message : Error in Workflow
Any suggestion is welcomed Thanks all !