If no 1 fails, start no 2

Hello, I would like that when my node has a problem, knime will automatically start the node below

My english is not the best, sorry

Hi @gabrielfs2,

checkout the try-catch nodes.
They provide error handling to your workflow:

2 Likes

*would look something like this

5 Likes

hi, thanks for the reply.

I noticed that it started 2 node along with 1 node.

the idea would be to only start the 2 node if the 1 does not run

1 Like

Hi @gabrielfs2 , and welcome to the KNIME Community.

The above flow is along the right lines, but I think you need a small adjustment to something like this:

The lower output port on the Catch Errors returns error messages and so cannot be used to redirect the flow.

One possible option is to supply an empty table to the Catch Errors (Data Ports) lower input flow, so that when an error occurs, an empty data set is returned. This is then tested using an Empty Table Switch which will pass flow up, if no error occurred (and the data table isn’t empty) or down if an error occurred (table is empty).

Now if your lower flow were then a data flow, that would be the end of the matter, but because you want to activate a CSV Reader on the “empty” flow, you have a problem as it cannot be connected to the lower data port. You therefore need to stick a node here that can. I have added my “Pass-through” component which acts a dummy recipient of the lower data port simply so that it can then activate the CSV Reader via a flow port.

You can find the “Pass Through” component here:Pass-through – KNIME Hub

Alternatively instead of this, you can add an Add Empty Rows node and configure it to add exactly zero rows (which is actually what my Pass-through component does).

A similar approach is to use a variable to guide the flow via an IF switch. Here a String variable called “flowbranch” is set to “bottom” prior to the Try-Catch nodes. This means that if the CSV Reader fails, the flow will be directed to the bottom flow via the IF Switch which is configured to set the port according to the “flowbranch” variable. If the CSV Reader succeeds within the Try-Catch, the value of “flowbranch” is replaced with “top” via a second String Manipulation (Variable) node. So it can only take the top branch if the CSV Reader didn’t fail… You still need the dummy node on the lower branch of the IF for the same reasons as before. The difference here is that a valid file containing no rows doesn’t trigger the error branch.

2 Likes

sorry about that - forgot the inverter :frowning:

KNIME_project36.knwf (52.9 KB)

Hope this or @takbb solution works for you :slight_smile:

2 Likes

I like that @AnotherFraudUser … I’d not spotted the Active Branch Inverter before.

I clearly have some reading to do but I think that will come in handy :slight_smile: thanks.

1 Like

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