From 7cab7fd80f85b9a7846b1d771aa3dce592ae5d42 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Thu, 13 Mar 2014 13:23:21 +0200 Subject: Improve error message when reusing UI instance (#13457) Change-Id: I49ec1e837a1a2a04dfadef5fd5fb5b6fd10ffcbc --- server/src/com/vaadin/ui/UI.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'server/src/com/vaadin/ui/UI.java') diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 746fa194ac..0412cb1882 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -601,7 +601,18 @@ public abstract class UI extends AbstractSingleComponentContainer implements */ public void doInit(VaadinRequest request, int uiId) { if (this.uiId != -1) { - throw new IllegalStateException("UI id has already been defined"); + String message = "This UI instance is already initialized (as UI id " + + this.uiId + + ") and can therefore not be initialized again (as UI id " + + uiId + "). "; + + if (getSession() != null + && !getSession().equals(VaadinSession.getCurrent())) { + message += "Furthermore, it is already attached to another VaadinSession. "; + } + message += "Please make sure you are not accidentally reusing an old UI instance."; + + throw new IllegalStateException(message); } this.uiId = uiId; -- cgit v1.2.3