Exception Handling

Each exception thrown by a method call initiated by the framework is handled by the framework. There is a sophisticated excepition handling integrated in the framework. This mechanism may not only be used for errors. It is also useful to handle gui validation errors using exceptions.

Each controller must implement the method

public Gui4jExceptionHandler getExceptionHandler()
{
  …
}

If an exception t of type T occurs during a call initiated by gui4j, the instance returned by the above method is searched for methods with the following signature:

public void handleException(T exception)
{
  …
}

If no such method can be found, then the search continues with the super types of T. If no method can be found for each super type, then the method

public Gui4jExceptionHandler getDelegationExceptionHandler()
{
  …
}

is executed and the search continues with that instance.
If after searching in all exception handlers and for all super types, no proper method was found, then an internal error is raised. An error handler for these internal errors can be specified in the Gui4j instance which was necessary to initialize the framework. The default error handler simply shows a JOptionPane with the error message.