Reformat: ERROR showing incorrect Record number

Hi,

I have a transformation class that throws a TransformException. My REFORMAT_0 node uses this transformation class.

When my class throws an exception, looks like the Record number reported by WatchDog is incorrect… it always show Record number 0, although it is not the first record in my data that is causing the exception to be thrown.

this is an example of my TransformException message:

ERROR [WatchDog] - Node REFORMAT_0 finished with status: Error occurred in nested transformation: ERROR caused by: Record number: 0, field number: 0. Message: Delimited input data parses into 15 fields, but FMT has 16 fields…

Please verify and let me know if I have a way to overwrite the Record number counter so that the correct Record number is reported.

Thanks,
al

Hello,
this message is probably generated by your data parser. Data parser has to set error record and field numbers. Could you show your transformation code?

Hi Agata,

here is my transform method in my transform class:

public boolean transform(DataRecord _source, DataRecord _target)
throws TransformException {

DataRecord source = _source[0];
DataRecord target = _target[0];

target.reset();

DataField sourceField = source.getField(0);
String fieldName = sourceField.getMetadata().getName();

Object srcValue = TransformUtils.getDataFieldValue(fieldName, source, false);

if (srcValue == null) {
return false;
}

List parseStr;

String fieldDelimiter = target.getMetadata().getFieldDelimiterStr();
parseStr = DelimitedDataParser.parseData(srcValue.toString(), fieldDelimiter, quoteChar);

if (parseStr.size() != target.getNumFields()) {

throw new TransformException(new StringBuffer(" Delimited input data parses into “).append(parseStr.size()).append(” fields, but FMT “).append(target.getMetadata().getName()).append(” has “).append(target.getNumFields()).append(” fields.").toString());

}

for (int i = 0; i < target.getNumFields(); i++) {

DataFieldMetadata metadata = target.getField(i).getMetadata();
fieldName = metadata.getName();
String value = parseStr.get(i);

TransformUtils.setDataFieldValue(value, fieldName, target, false, null);
}

return true;
}

let me know if you need more info… can i email you my code?

Thanks,
al

Hi,
you have to set record and field number to your TransformException. You can do it in constructor or by setters.

Hi Agata,

Thanks!!

al