Book Image

Vaadin 7 Cookbook

Book Image

Vaadin 7 Cookbook

Overview of this book

Table of Contents (19 chapters)
Vaadin 7 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Blocking uncaught exceptions in the production mode


The client's browser is always informed whenever something bad happens on the server and an uncatched exception is thrown.

We can simulate that quite easily. Just create a new application and add the following code there:

protected void init(VaadinRequest request) {
   VaadinService service = request.getService();
   DeploymentConfiguration deploymentConfiguration = service.getDeploymentConfiguration();
   boolean productionMode = deploymentConfiguration.isProductionMode();
   if (productionMode) {
      ProductionErrorHandler errorHandler = new ProductionErrorHandler();
      setErrorHandler(errorHandler);
   }

   final VerticalLayout layout = new VerticalLayout();
   layout.setMargin(true);
   setContent(layout);

   Button button = new Button("Throw an error please");
   button.addClickListener(new Button.ClickListener() {
   public void buttonClick(ClickEvent event) {
   layout.addComponent(new Label("Click and bang!"));
      throw...