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]
How to email Talend job error information in Talend Open Studio Data Integration
Create a new sample application
abc,def,ghi 123,456,789
Raise an error in tFileInputDelimited component
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