Handling logs and exceptions - Cloud - 7.3

Talend Studio User Guide

Version
Cloud
7.3
Language
English
Product
Talend Big Data
Talend Big Data Platform
Talend Cloud
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Design and Development
Last publication date
2024-02-13
Available in...

Cloud API Services Platform

Cloud Big Data

Cloud Big Data Platform

Cloud Data Fabric

Cloud Data Integration

Cloud Data Management Platform

Data Fabric

Before you begin

About this task

When building Artifacts, you can use specific components to collect exception data and transfer it to the Studio console or to the web application.

When building Jobs, use:

  • tJobFailure to throw exception and stop the Artifact or Task execution
  • tLogCatcher to collect exception data and transfer it to the Studio console or to the web application
  • tJobLog to define log information when executing Jobs in the Studio or Tasks in the web application

The example below shows how to collect data exceptions in a Job.

Procedure

  1. Build a Job to call a web service.

    Example

  2. Open the Basic settings view of the tJobFailure component.
  3. Enter Execution failed as the error type in the Error Type field.

    You can define the error type according to your needs and the value you define in this field will show in the run detail page when you run a Task in the web application.

  4. Enter the Java expression for the message in the Error Message field.

    Example

    "Error during call service: " + row6.faultString + " details:" + (row6.faultDetail != null ? row6.faultDetail.toString() : null)

    This means an exception will be thrown in case fault comes as response from the SOAP service. You can define the error message according to your needs.

  5. Build a subJob using tLogCatcher, tJobLog (x2) and tJobFailure.

    If you have imported the demo project, you can drop a ready-to-use exception handling subJob from the Joblets node in the Repository tree view. For further information about the demo project, see the Getting Started with Talend Cloud guide.

  6. In the basic settings of the tLogCatcher component, select the Catch Java Exception and Catch tJobFailure options.

    The tLogCatcher component collects exception data and transfer it to the Studio console or to the web application.

  7. In the basic settings of the first tJobLog component, select the Developer option and define the log message as the following in the Log message field:
    "\n | Action: " + row1.job + "\n | Component: " + row1.origin + "\n | Error type: " + row1.type + "\n | Error code: " + row1.code + "\n | Error message: " + row1.message

    This logs the error messages to the Studio.

  8. In the basic settings of the second tJobLog component, select the User option and define the log message as the following in the Log message field:
    row2.message

    This logs the error messages to the web application.

  9. In the basic settings of the tJobFailure component, set Execution failed as the error type and set the Java expression for the message in the Error Message field as the following, for example:
    row3.job + ":" + row3.origin +": " + row3.message