Handle javascript step errors in kettle

Source: Internet
Author: User
Javascript step error handling if you are familiar with the incorrect features of kettle conversion, you may want to know how to use it in javascript steps. The steps and user interfaces that support the error mechanism are the same. Right-click the javascript step and select "define error handling" to enable and configure error handling. Javascript code can identify error lines and forward them to the configuration

Javascript step error handling if you are familiar with the incorrect features of kettle conversion, you may want to know how to use it in javascript steps. The steps and user interfaces that support the error mechanism are the same. Right-click the javascript step and select "define error handling" to enable and configure error handling. Javascript code can identify error lines and forward them to the configuration

Javascript Step Error Handling

If you are familiar with the incorrect features of kettle conversion, you may want to know how to use it in javascript steps. The steps and user interfaces that support the error mechanism are the same. Right-click the javascript step and select "define error handling" to enable and configure error handling. Javascript code can identify error lines and forward them to the configured error handling steps. The following parameters are required by using the putError () method of the _ step _ OBJECT:

1) RowMetaInterface Object Description row Structure

2) current error line

3) number of errors detected in this row

4) Error description string (error message)

5) name of the field that caused the error (string)

6) error code (string)

Normally, original, unmodified input rows are passed to the error handling step. Therefore, the first two parameters are usually specified as getInputRowMeta () andRow. Other parameters depend on how you describe the errors you encounter. The javascript step defines the error handling configuration. You can configure the fields to be output to the error handling step.

The conversion example first generates a random string. For the purpose of illustration, the javascript step determines that the letters 'A' and 'K' are missing from the preceding characters, and an error is returned when each letter is missing.

The javascript step contains 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 contain 'a' and 'k'",            nr_errors:2,            field:"value",            errcode:"ERR:003"        }    }    elseif(should_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:"Value must contain 'k'",            nr_errors:1,            field:"value",            errcode:"ERR:002"        }    }    //continue normally, passing the row on to the next step    trans_Status= CONTINUE_TRANSFORMATION;}catch(e){    //pert the current row to the error step and do not pass anything to thenext  step    _step_.putError(getInputRowMeta(),row, e.nr_errors, e.message, e.field, e.errcode);    trans_Status= SKIP_TRANSFORMATION;}

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.