Improved error handling of failure to connect to remote UI.

Review by: mmendez

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@7112 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/DevModeBase.java b/dev/core/src/com/google/gwt/dev/DevModeBase.java
index e58db6f..99c1a85 100644
--- a/dev/core/src/com/google/gwt/dev/DevModeBase.java
+++ b/dev/core/src/com/google/gwt/dev/DevModeBase.java
@@ -311,7 +311,7 @@
     public String[] getTagArgs() {
       return new String[] {"port-number:client-id-string | host-string:port-number:client-id-string"};
     }
-    
+
     @Override
     public boolean isUndocumented() {
       return true;
@@ -575,8 +575,7 @@
 
   private static final AtomicLong uniqueId = new AtomicLong();
 
-  public static String normalizeURL(String unknownUrlText, int port, 
-      String host) {
+  public static String normalizeURL(String unknownUrlText, int port, String host) {
     if (unknownUrlText.indexOf(":") != -1) {
       // Assume it's a full url.
       return unknownUrlText;
@@ -993,10 +992,16 @@
       newUI = new HeadlessUI(options);
     } else {
       if (options.useRemoteUI()) {
-        newUI = new RemoteUI(options.getRemoteUIHost(),
-            options.getRemoteUIHostPort(), options.getClientId(),
-            options.getPort(), options.getCodeServerPort());
-        baseLogLevelForUI = TreeLogger.Type.TRACE;
+        try {
+          newUI = new RemoteUI(options.getRemoteUIHost(),
+              options.getRemoteUIHostPort(), options.getClientId(),
+              options.getPort(), options.getCodeServerPort());
+          baseLogLevelForUI = TreeLogger.Type.TRACE;
+        } catch (Throwable t) {
+          System.err.println("Could not connect to remote UI listening at "
+              + options.getRemoteUIHost() + ":" + options.getRemoteUIHostPort()
+              + ". Using default UI instead.");
+        }
       }
     }