I’m using the “Catch Errors (Data Ports)” node and need the error message stored in the _error_reason variable. For this I use the “Variable to Table Row” node including the variable “FailingNodeMessage”, which was available when I’ve set up the node. But when I execute the workflow I get the message that this variable does not exist.
Haven’t seen this one before. Which KNIME version are you using? Are these _error_stacktrace, _error_reason and _error_node variables created by yourself and if yes in which node?
If you want the error message (value from flow variable FailingNodeMessage) to be stored in a flow variable called _error_reason you can create flow variable inside Catch Errors node like this:
On Flow Variables tab add _error_reason to the text field on the right of appropriate configuration setting.
FailingNodeMessage flow variable is changed to test just to verify we configured a right option on Flow Variables tab as all are none by default.
Upon node execution _error_reason flow variable is created and has the same value (test) as FailingNodeMessage flow variable.
I’m using KNIME 3.7.1. The variables _error_stacktrace, _error_reason and error_node were not created by myself but they appear after the first workflow execution, when the database exception ORA-00001 was raised and got by Catch Errors node. So, after the first execution, I opened the Catch Errors (Data Ports) node and the variables were available for selection. I’ve selected _error_reason variable and clicked on OK button. Immediately the message ‘WARN Catch Errors (Data Ports) 2:41 Errors overwriting node settings with flow variables: Unknown variable “_error_reason”’ appears. I’m not sure if the variables _error_stacktrace, _error_reason and error_node were available because I activated the option Error Handling on “Database Writer” node.
I’ll follow the instructions you suggested and I will post the results.
I’ve applied the solution of create a variable named _error_message, as you suggested before. Now there is no error, but this variable do not catch the reason for error raised by Database Writer node, because _error_message was created by myself.
It appears the variables _error_stacktrace, _error_reason, _error_node and _error_caught are available only after a iteration that raised an error (see the image below).
I don’t know how to get the exception that Database Writer raises, as the value returned in the _error_reason variable is the default value of FailingNodeMessage option of Cath Errors (Data Ports) node.
_error_reason and others are indeed created and I’m able to chose it as well. Obviously that resets node and they are gone meaning you have error. I need to explore this a bit more and will get back to you. Also will try to give you and example how to use Try/Catch with Database Writer node.
Sry for a delay on this one. Here is an example how to use Try/Catch sequence while writing to Database. You have to use Catch Error (Var Ports) in order to get errors from database Writer node. For start I used Try (Variable Ports) but it can work with Data Ports as well. Here is a print screen.
Additionally I have done same using New Database Integration nodes. There you have DB Insert node that offers more possibilities in configuration and more information in data output port. Check these new nodes out as they are planned to be production ready in KNIME summer release