Hello!
I am trying to use the reformat component to convert data types in Clover 2.9.6. The problem is that I want to skip records that fail conversion instead of having the graph execution failing. I read in the TL documentation that I could use a try/catch block but I am having a lot of trouble making it work. Currently, I am running the following code:
//#TL
string message;
function transform() {
string errMsg;
try {
$0.valores := iif(isnull($0.valores), null, try_convert($0.valores, decimal));
} catch (errMsg) {
message = 'Failed for field $0.valores value '+$0.valores+' msg '+errMsg;
return -1;
}
}
function getMessage() {
return message;
}
If I remove the try/catch block, leaving only the code in the “try” section it works, but I need the error handling. The error message that clover throws is the following:
Encountered “$0.valores” at line 6, column 1.
Was expecting one of:
“;” …
“{” …
“}” …
“break” …
“continue” …
“for” …
“foreach” …
“if” …
“return” …
“while” …
“switch” …
“do” …
“try” …
“read_dict” …
“write_dict” …
“delete_dict” …
…
“isnull(” …
“nvl(” …
“nvl2(” …
“iif(” …
“print_stack(” …
“breakpoint(” …
“raise_error(” …
“print_err(” …
“eval(” …
“eval_exp(” …
“print_log(” …
“sequence(” …
“lookup(” …
“lookup_next(” …
“lookup_found(” …
“lookup_admin(” …
Please notice that “valores” is a valid input field for the reformat node.