Thursday, 19 September 2013

propogating error upwards in java

propogating error upwards in java

I have a main class where I have something like
void FooBar(String s){
try {
parseString(s);
} catch (Exception e) {
e.printStackTrace();
System.err.println("Error: " + e.getMessage());
context.getCounter(Counters.ERROR).increment(1); // this increment
doesnt increases
}
}
parseString is
void ParseString(String s){
if (matcher.matches()) {
}
else{
//throw exception
try {
throw new Exception("bad formatted N-triples");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
But for some reason, the error is not propogated upwards...So in my FooBar
method.. the error counters are not incremented even if the function gets
bad formatted data..
How do I propagate this exception upwards?

No comments:

Post a Comment