// Create a button with an event handler that will throw an exception.
Document doc = Browser.getDocument();
ButtonElement btn = doc.createButtonElement();
doc.getBody().appendChild(btn);
btn.addEventListener(Event.CLICK, new EventListener() {
@Override
public void handleEvent(Event evt) {
throw new RuntimeException("w00t!");
}
}, false);