]> source.dussan.org Git - vaadin-framework.git/commitdiff
Improve message when session is already set (#9989) 35/135/1
authorLeif Åstrand <leif@vaadin.com>
Thu, 18 Oct 2012 09:38:24 +0000 (12:38 +0300)
committerLeif Åstrand <leif@vaadin.com>
Thu, 18 Oct 2012 09:38:24 +0000 (12:38 +0300)
Change-Id: If75868863999f61d014402eb98c74a142dc22c4a

server/src/com/vaadin/ui/UI.java

index 2878d10fa1890161b02227fbfcd02fc0de3b7812..d57d38b371ef0a0b7631effb0d406c354b8d8be0 100644 (file)
@@ -709,7 +709,10 @@ public abstract class UI extends AbstractComponentContainer implements
     public void setSession(VaadinServiceSession session) {
         if ((session == null) == (this.session == null)) {
             throw new IllegalStateException(
-                    "VaadinSession has already been set");
+                    "VaadinServiceSession has already been set. Old session: "
+                            + getSessionDetails(this.session)
+                            + ". New session: " + getSessionDetails(session)
+                            + ".");
         } else {
             if (session == null) {
                 detach();
@@ -722,6 +725,15 @@ public abstract class UI extends AbstractComponentContainer implements
         }
     }
 
+    private static String getSessionDetails(VaadinServiceSession session) {
+        if (session == null) {
+            return null;
+        } else {
+            return session.toString() + " for "
+                    + session.getService().getServiceName();
+        }
+    }
+
     /**
      * Gets the id of the UI, used to identify this UI within its application
      * when processing requests. The UI id should be present in every request to