Handling exception is always a challenge in Enterprise application. When the project is big and you have lot of people working in the project, it becomes necessary that you have common mechanism for handling the exception in your project.

In GWT Enterprise Application, You basically need to handle 2 types of exception.

  1. GWT Code Exception
  2. RPC Call Exception

Today we will discuss how to handle GWT Code Exception in a generalized manner. We need to follow the below mentioned steps for the same.

  • Create a class with the naming standards, which you have been following on GWT side code.
  • That class should extend com.google.gwt.core.client.GWT.UncaughtExceptionHandler class. Say for example our Class name is CommonExceptionHandler.
  • Now we need to overwrite the below mentioned method in that class


public void onUncaughtException(Throwable caught)


  • In the upper mentioned method, write the code which you would like to get executed when exception comes in your application.
  • Now in order to register this class as a exception handler class, Open the GWT Entry point class of your application.
  • In that Entry point class , go to onModuleLoad() method
  • In onModuleLoad() method , put the below mentioned statement as the first statement.

GWT.setUncaughtExceptionHandler(new CommonExceptionHandler ());

That’s IT. With this in place, Whatever exception comes in you application, will be routed to onUncaughtException() method.

Written by SPECIndia

SPEC INDIA is a ISO 9001:2008 software solutions company based in Ahmedabad, India. Starting its journey in 1989 with just three professionals, SPEC INDIA has grown in revenue and human resource strength by building information bridges between technology and business processes.