Basic Error Handling in Talend Open Studio Data Integration

Basic Error Handling in Talend Open Studio Data Integration

Why do we need to implement error handling?

This article explains why we need to implement error handling in Talend Open Studio Data Integration and talk about error handling basics. Any applications and jobs should have error handling code. If we don't have error handling code, those are not good.

For example, when something happened in Windows, Windows tells us what happened and give us some informative message. If Windows or application doesn't tell us what happened, Windows or application may disappear without saying anything. As a result of that, users don't know what to do. If we implement error handling, we know what happened and what to do, therefore let's implement error handling in Talend.

[Related posts]
Basic Error Handling in Talend Open Studio Data Integration
How to email Talend job error information in Talend Open Studio Data Integration



Create a new sample application

In order to understand error handling basics in Talend, let's create a new sample application. We create "test" job for testing. It reads CSV file and display the CSV file contents.

We use tFileInputDelimited component to read CSV file and display the CSV file contents by using tLogRow component as the following image.

We configure tFileInputDelimited component as follows. It reads "C:/Talend/testdata/test.csv" file.

"C:/Talend/testdata/test.csv" file contents is as follows.
abc,def,ghi
123,456,789

Since we need to define columns to read the CSV file, we need to click "Edit schema" button. Let's add 3 columns as follows.

Now, let's run the job. tFileInputDelimited read two records, then displayed the two records as following image.

Raise an error in tFileInputDelimited component

Let's see what happens when a component raised an error. We change CSV file name in tFileInputDelimited setting to raise an error. Let's change file from "C:/Talend/testdata/test.csv" to "C:/Talend/testdata/test.csvv", so that the tFileInputDelimited component cannot read the file which doesn't exist.

When we ran the job, data was not loaded and error message says a component cannot read the file. We got error message "C:\Talend\testdata\test.csvv (File doesn't exist)".

According to the result, even when file read failed, tLogRow component was called with zero rows. (0 rows in designer window).

We know what happened by reading the error message, but cannot take any actions. We need to catch the error and need to take an action.

In order to solve the issues, we need to turn on "Die on error" option in tFileInputDelimited component (green circle in the following image). Once wee turned on the options, the component dies immediately and doesn't call any other components.


Let's run the job with "Die on error" option. tLogRow component was not called as follows. Also, we see more detail error message as the following image (Java exception message is printed). However, we still cannot catch error and cannot take any actions, so we need to do something else.


Catch error on tLogCatcher component

We somehow need to catch error in Talend job. In order to catch error in job, we need to use tLogCatcher component.

tLogCatcher catches error automatically. The component needs requires output component, so let's use tLogRow component to output error information.

We have no relationship between tFileInputDelimited and tLogCatcher, but this is OK since tLogCatcher catches any errors automatically. If you know Java, tLog Catcher wraps entire job by using try {} catch {}.



Then, let's run the job again. As the following image, error was caught on tLogCatcher component. Once an error was caught, tLogCatcher component calls connected component (tLogRow). So that the tLogRow displays error message.

Displayed error message through tLogCatcher (green circled message) tells us when the error happened and job name (test) as well as component name (tFileInputDelimited_1), Java Exception message and some other useful information.

Once we caught the error, we can write the error information into log file or can email.

We learned error handling basics in Talend Open Studio Data Integration. We will learn more about error handling.

How to email Talend job error information in Talend Open Studio Data Integration