You are not logged in.
Announcement
Unanswered posts
|
emaxt6 wrote:
You can design your custom parse routine so that it returns value null when the string can't be correctly parsed; then in tmap you can put a filter condition to an additional flow where rows with "null" in the date field go; so you can fully log all the rejected rows ( in file or database ).
bye
Sounds a good idea ^^. I'll do it this way, but this would be really great if one could fully use javaExceptions to cope with unusual but still possible errors.
You can design your custom parse routine so that it returns value null when the string can't be correctly parsed; then in tmap you can put a filter condition to an additional flow where rows with "null" in the date field go; so you can fully log all the rejected rows ( in file or database ).
bye
@emaxt6 that's just what I want to do: not allow garbage in. Sadly I can't get my tFileOutput to reject some strings that are to be parsed in a custom way (say a 14 character string with a meaning for the 11 first characters and another for the last three). That's why I tried to throw an exception in order to stop treatment on a wrong line and catch it in a tCatcher.
I would design the thing differently... I wouldn't allow garbage in... if you can't parse a field supposed date you should crash the job or log the row in a reject flow....
Anyway, I haven't tried, but what happens when you throw a unchecked exception like derived from RuntimeException ( encapsulate your exception in RuntimeException )? ie. "throw new RuntimeException(myexception)" ??
Does nobody know how to do the trick: let me explain further:
My function is used in a tMap and if I use a "throws" it is logged properly in my "ontrol" base but the tMap dies, which is not the behavior I want. If I use a try/catch, the job does not die but the tCatcher is not reached, which is not my aim either.
How could I do it?
Morbo wrote:
Hello,
This would do the trick :Code:
public static Date ParseDateFromStringNoThrow(String s) { try{ return ParseDateFromString(s); } catch(ParseException e) { //DO SOMETHING USEFULL TO LOG IT return null; } }
Ok, I would like to use something like that, but then, how could I log it using tLogCatcher? I would like to proceed this way because I log errors in a 2nd dataBase and I use all the tLogCatcher outputs to create the database logs. I suspect that using a try/catch/finally block wouldn't allow me to redirect a message to the catcher?
Hello,
This would do the trick :
public static Date ParseDateFromStringNoThrow(String s) {
try{
return ParseDateFromString(s);
}
catch(ParseException e)
{
//DO SOMETHING USEFULL TO LOG IT
return null;
}
}Hi!
I would like to how how to fully deal with java errors. As an exemple I got a function (ParseDateFromString) in routines (let say static class is MyRoutines). The function definition is the following:
public static Date ParseDateFromString(String) throws ParseException {
...
}
I know that using a tLogCatcher I can catch those errors, but whatever I can't manage not to print the stacktrace on console which I doesn't wish. How could I change this behavior. I appreciate a lot the SQL errors systems which are logged on console except when you create a reject link.
Thanks,
Diane