I would like to trap str2date() errors in my CTL code, however, for cases where the incoming format is unexpected then the whole graph assembly fails. I was hoping the transformOnError() function would handle this so I could perform some action (e.g. SKIP or write to a separate output port) but the whole job just terminates.
How can i trap this sort of error and introduce some sort of handling?
There are 2 options, how to handle it. One works only with the newest CloverDX release (5.6), the second even in older versions. But both should be used in interpreted mode of CTL.
Can’t really answer that… would need to see the whole transform() & transformOnError() function you have. In general, onError() is called when exception is raised in transform(). If your transformOnError() returns SKIP (constant), then current record is skipped and processing continues with the next one. If you return ALL, then whatever was already written to $out. is sent out (means can be partially updated output record). Of course, you can abort the whole processing inside transformOnError() if you return negative number or call raiseError() function.