Time for action—aborting when there are too many errors

  1. Open the transformation from the previous tutorial and save it under a different name.
  2. From the Flow category, drag an Abort step to the canvas.
  3. Create a hop from the Write to log step to the Abort step.
  4. Double-click the Abort step. Enter 5 as Abort threshold. As Abort message, type Too many errors calculating age of film!.
  5. Click OK.
  6. Select the Dummy step and do a preview. As a result, a warning window shows up informing you that there were no rows to display. In the Step Metrics tab, the Abort after 5 errors line becomes red to show you that there was an error:
    Time for action—aborting when there are too many errors
  7. The log looks like this:
    ... - Bad rows.0 -
    ... - Bad rows.0 - ====================
    ... - Abort after 5 errors.0 - Row nr 6 causing abort : [Trois couleurs - Blanc], [null], [Comedy | Drama], [Krzysztof Kieslowski], [Zbigniew Zamachowski, Julie Delpy], [2009/08/18 00:00:00.000], [
    ... - Abort after 5 errors.0 - Javascript error:
    ... - Abort after 5 errors.0 - Could not apply the given format dd/MM/yyyy on the string for 01/01/null : Format.parseObject(String) failed (script#4)
    ... - Abort after 5 errors.0 -
    ... - Abort after 5 errors.0 - --> 4:0], [SCR-001]
    ... - Abort after 5 errors.0 - Too many errors calculating age of film!
    ... - Abort after 5 errors.0 - Finished processing (I=0, O=0, R=6, W=6, U=0, E=1)
    ...
    ... - Spoon - The transformation has finished!!
    ... - error_handling_with_abort - ERROR (version 3.2.0-GA, build 10572 from 2009-05-12 08.45.26 by buildguy) : Errors detected!
    

What just happened?

You forced the abortion of a transformation after five erroneous rows.

Aborting a transformation using the Abort step

Through the use of the Abort step, you force the abortion of a transformation. Its main use is in error handling.

You can use the Abort step to force the abortion as soon as a row arrives to it, or after a certain number of rows as you did in the tutorial. To decide between one and the other option, you use the Abort threshold option. If threshold is 0, the Abort step will abort after the first row arrives. If threshold is N, the Abort step will cause the abortion of the transformation when the row number N+1 arrives at it.

Beyond the error handling situation, you may use the Abort step in any unexpected situation. Examples of that could be when you expect parameters and they are not present or when an incoming file is empty when it shouldn't be. In situations like these, you can force an abnormal ending of the execution just by adding an Abort step after the step that detects the anomaly.

Fixing captured errors

In the Time for action—capturing errors while calculating the age of a film section of this chapter, you sent the bad rows to the log. However, when you capture errors, you can send the bad rows toward any step as long as the step knows how to treat those rows. Let's see an example of that.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.90.182