When a node encounters an error, is it possible to display what node and what error message in the console?

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 :slight_smile: Thanks all !

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @Jessy_HF

Thanks for posting here and welcome to the community! :cake:

Do you need to have the error in the browser console?

n8n has built-in error handling and you can retrieve all data about an execution error with the Error Trigger node. You have a lot of flexibility how you want to be notified about the error that was thrown by simply building out an error workflow with this node.

All you need to do is then change the settings of your production workflows to send errors to your dedicated error workflow.

Have a look in our documentation:

Hope this little demo helps:

:slight_smile:

2 Likes

Hello Nia, thank you for your reply. By looking at your demo, it seems like it’s exactly what we’re looking for ! I’ll look into the documentation for that, thanks a ton.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.