Handle Runtime Exceptions In Echo2
I was looking for a transparant mechanism to handle runtime exceptions in Echo2. Apparently Echo2 does not provide any hook for gracefully handling runtime exceptions due to the following posts. Since one solution lost access to the current Application Instance and the other involved changing Echo2 source code, I have found my own solution to this problem:
public class ExceptionalUpdateManager extends UpdateManager{
private static final long serialVersionUID = 1L;
public ExceptionalUpdateManager(ApplicationInstance applicationInstance) {
super(applicationInstance);
}
public void processClientUpdates()
{
try{
super.processClientUpdates();
}catch(AbstractHrutilRuntimeException exception){
//Hook : I show an error popup with the translation of the error code.
TopContentPane.getTopContentPane().add(new ErrorPane(exception.getErrorCode()));
}
}
}
and I overwrite (little bit of hacking with reflection) the UpdateManager of the ApplicationInstance as follows:
public ApplicationInstanceChild() {
super();
ReflectionUtil.setField(this, "updateManager", new ExceptionalUpdateManager(this));
}
This should solve the problem ! Every time a runtime exception is propagated, an error popup is shown with a description of the problem.
Labels: Echo2, runtime exceptions
