# Handle error in reformat component

**URL:** <https://forum.cloverdx.com/t/handle-error-in-reformat-component/21>\
**Category:** CloverDX Platform\
**Created:** [July 16, 2007, 12:00am UTC](https://forum.cloverdx.com/t/handle-error-in-reformat-component/21 "2007-07-16T00:00:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![oldforum](https://avatars.discourse-cdn.com/v4/letter/o/13edae/32.png) [@oldforum](https://forum.cloverdx.com/u/oldforum)\
**Post date:** [July 16, 2007, 12:00am UTC](https://forum.cloverdx.com/t/handle-error-in-reformat-component/21/1 "2007-07-16T00:00:00Z")

</div>

Hi every body !

I use the “reformat” component to process transformations on DataRecord thanks to a java class. These transformations could fail, so I would send failing record in a second output port, something like that (pseudo code, output port 0 = transformation OK, output port 1 = error encountered) :

try {  
(outputRecords[0].getField(0)).setValue( transformation(inputRecords[0].getField(0).toString() ));  
etc.  
} catch (transformationException te) {  
outputRecords[1].copyFrom(inputRecords[0]);  
}

My problem is that I don’t want to send anything to outpu port 0 if I find an error, and conversely I don’t want to send anything to outpu port 0 if the process goes fine. outputRecords[0].setToNull() is not a solution, some field are required (nullable=false).

Is their a solution to do that with the standard reformat component, or should a develop my one ?

Thanks for your help (and sorry for my english).

---

<div class="post-metadata">

**Author:** ![oldforum](https://avatars.discourse-cdn.com/v4/letter/o/13edae/32.png) [@oldforum](https://forum.cloverdx.com/u/oldforum)\
**Post date:** [July 16, 2007, 8:23am UTC](https://forum.cloverdx.com/t/handle-error-in-reformat-component/21/2 "2007-07-16T08:23:44Z")

</div>

Yes, this is a simple work around for my secific problem. I posted it just as an information, to say that my work goes on, and the way it goes.  
In fact I encounter the problem you discribe : I needed to remove the “not nullable” attribute of metadata to have this solution works. The nullity check of source data is made before, in a “normalizer” component.

Well, it’s just a (perfectible) tips for my problem, and it is cool that it rises some response. Of course, I eventually search a better solution 🙂

Francois

---

<div class="post-metadata">

**Author:** ![oldforum](https://avatars.discourse-cdn.com/v4/letter/o/13edae/32.png) [@oldforum](https://forum.cloverdx.com/u/oldforum)\
**Post date:** [July 16, 2007, 8:23am UTC](https://forum.cloverdx.com/t/handle-error-in-reformat-component/21/3 "2007-07-16T08:23:45Z")

</div>

What if the interface definition of RecordTransform would change to return not false-true but number.  
That could be used like this:

-1 (or negative number) - error  
0 - O.K. send the out records  
\>0 (positive number) indicates the one output port through which data will be sent (all others receives nothing)

Anyway, this is more a development discussion - we should move it to different forum.

David

---

<div class="post-metadata">

**Author:** ![oldforum](https://avatars.discourse-cdn.com/v4/letter/o/13edae/32.png) [@oldforum](https://forum.cloverdx.com/u/oldforum)\
**Post date:** [July 16, 2007, 8:23am UTC](https://forum.cloverdx.com/t/handle-error-in-reformat-component/21/4 "2007-07-16T08:23:46Z")

</div>

Ok, I find a solution replacing this code in Reformat :  
---------  
if (transformation.transform(inRecord, outRecord)) {  
for(outPort=0;outPort\<numOutputPorts;outPort++){ writeRecord(outPort, outRecord[outPort]);  
}  
}  
}// skip record if transformation returned false  
---------  
By this one :  
----------  
if (transformation.transform(inRecord, outRecord)) {  
for(outPort=0;outPort\<numOutputPorts;outPort++){  
if(!outRecord[outPort].isNull()) {  
writeRecord(outPort, outRecord[outPort]);  
}  
}  
}// skip record if transformation returned false  
----------  
And in the java transformation class, if a transformation fails, I set the standard (0) output to null thanks to outputRecord[0].setToNull() and copy input to the error output (1).

If it may help others…

---

<div class="post-metadata">

**Author:** ![oldforum](https://avatars.discourse-cdn.com/v4/letter/o/13edae/32.png) [@oldforum](https://forum.cloverdx.com/u/oldforum)\
**Post date:** [July 16, 2007, 8:23am UTC](https://forum.cloverdx.com/t/handle-error-in-reformat-component/21/5 "2007-07-16T08:23:47Z")

</div>

Hello,  
this solution could be suitable for your proprietary issue, but isn’t generally recommended, for DataRecord.setToNull() could throw NullPointerException if some field is not nullable and simultaneously has not default value defined. In short, this way is not possible for some type of metadata.

Martin
