JavaScript step error handling in kettle

Source: Internet
Author: User

JavaScript Step error Handling

If you are familiar with the error features of the kettle conversion, you may want to know how to use it in JavaScript steps. Steps to support the error mechanism the user interface mechanism is the same, right-click on the JavaScript step, select "Define error Handling" To enable error handling and configure. The JavaScript code can identify the error lines and forward them to the configured error handling steps, which require the following several parameters by using the Puterror () method of the _step_ object:

1) Rowmetainterface Object Description Row structure

2) the current error line

3) Number of errors detected on this line

4) Error description string (Error message)

5) field name (string) that caused the error

6) Error code (string)

Typically, the original, unmodified input line is passed to the error-handling step. As a result, the first two parameters are typically specified as Getinputrowmeta () and row. The other parameters depend on how you want to describe the error you are encountering. The JavaScript step defines the error handling configuration that can be configured for those field output to the error handling step.


The example of this conversion first generates a random string. For illustrative purposes, the JavaScript step determines that the previously generated characters are missing the letters ' a ' and ' K ', and each missing letter produces an error.

The JavaScript steps contain the following code:


Varshould_error_on_a= (Value.indexof ("a") = =-1)? 1:0;varshould_error_on_k= (Value.indexof ("k") = =-1)? 1:0; try{if (should_error_on_a== 1 && should_error_on_k = = 1) {throw{message: "Value must Contai N ' a ' and ' K ' ", Nr_errors:2, Field:" Value ", Errcode:" Err:003 "}} elseif (Sho uld_error_on_a== 1) {throw{message: "Value must contain ' a '", Nr_errors:1, field: " Value ", Errcode:" err:001 "}} elseif (should_error_on_k== 1) {throw{message:" Val UE must contain ' K ' ", Nr_errors:1, Field:" Value ", Errcode:" Err:002 "}}//co  Ntinue Normally, passing the row on to the next step trans_status= continue_transformation; }catch (e) {//divert The current row to the error step and do not pass anything to Thenext step _step_.puterror (Geti Nputrowmeta (), row, E.nr_errors, E.message, E.field, E.errcode);   Trans_status= skip_transformation;} 

JavaScript step error handling in kettle

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.