Handling errors
This scenario applies only to Talend Data Management Platform, Talend Big Data Platform, Talend Real-Time Big Data Platform, Talend MDM Platform, Talend Data Services Platform, Talend MDM Platform and Talend Data Fabric.
This following scenario creates a six-component Job that shows how to handle error conditions using the tHMap component.
When tHMap executes a Talend Data Mapper map, an ExecutionStatus object is always returned. A pointer to this object is stored in the globalMap as <tHMap_id>_EXECUTION_STATUS. In addition, the Overall Severity numeric value is also stored in the globalMap as <tHMap_id>_EXECUTION_SEVERITY.
Finally, a parameter called Exception Threshold is defined that specifies the severity on which to throw an exception, thus triggering Job-related or component-related error processing. This value can be defined in the tHMap properties, in the Advanced settings tab. The default value for this parameter is Fatal.
-
getOverallSeverity(): returns the numeric value of the highest
severity level.
- INFO is returned as 1
- WARN is returned as 2
- ERROR is returned as 4
- FATAL is returned as 0x40
- isOK(): returns true if there is no warning, error or fatal status.
- exportToXml(writer): writes the status items in XML format.
-
getFirstNonInfo(): returns an object of class
org.talend.transform.runtime.common.StatusItem, which corresponds
to the first status item with a severity higher than INFO. If there
are only items with the INFO status, this method returns null.
In this org.talend.transform.runtime.common.StatusItem object, you can use the getAsText() method, which returns a description of the status item as a human-readable formatted string.
- getItem(int_index): returns the status item at the given index in the collection of items. The index is zero-based.
- getFirstNonInfoIndex(): returns the index of the first status item with a severity higher than INFO in the collection of items. This is the index of the item that getFirstNonInfo() would return. This method returns -1 if there are no items with a severity level higher than INFO.