Commit cf4b37c1 authored by R.W.Majeed's avatar R.W.Majeed

count errors

parent abdd9429
......@@ -29,17 +29,23 @@ import de.sekmi.histream.ObservationHandler;
public abstract class AbstractObservationHandler implements ObservationHandler{
private Consumer<ObservationException> errorHandler;
private int errorCount;
@Override
public final void accept(Observation observation) {
try {
acceptOrException(observation);
} catch (ObservationException e) {
errorCount ++;
e.setObservation(observation);
reportError(e);
} // don't catch runtime exceptions
}
/**
* Report observation exception
* @param e exception
*/
protected void reportError(ObservationException e){
if( errorHandler != null )errorHandler.accept(e);
else throw new RuntimeException("Exception encountered, no error handler", e);
......@@ -58,4 +64,9 @@ public abstract class AbstractObservationHandler implements ObservationHandler{
this.errorHandler = handler;
}
/**
* Get the number of errors encountered
* @return error count
*/
public int getErrorCount(){ return errorCount;}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment