dimanche 20 décembre 2009

GWT exception management

To handle exceptions in GWT, like in java we use blocks try / catch / finally.
Unfortunately, runtime exceptions can be forgotten if we do not use a try / catch / finally overall. 
GWT programs are highly asynchronous, and this characteristic force us to declare many blocks try / catch / finally. It is therefore not immune to a NullPointerException ...


Fortunately GWT provides a special handler to catch exceptions not caught : UncaughtExceptionHandler.
Once implemented the method "public void onUncaughtException (Throwable e)"
receive all the exceptions not catched. This solution is simple, effective and elegant, can be implemented afterwards without impacting the structure of the program.

Aucun commentaire:

Enregistrer un commentaire