From 10e1469cfd48aafefdcda5c515eff09f7b3eb85e Mon Sep 17 00:00:00 2001 From: BetaSteward Date: Sun, 30 Oct 2011 21:15:14 -0400 Subject: [PATCH] improved cannot connect error message --- Mage.Common/src/mage/remote/Session.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Mage.Common/src/mage/remote/Session.java b/Mage.Common/src/mage/remote/Session.java index e01d307af4..e0f2c2b465 100644 --- a/Mage.Common/src/mage/remote/Session.java +++ b/Mage.Common/src/mage/remote/Session.java @@ -29,8 +29,10 @@ package mage.remote; import java.net.Authenticator; +import java.net.ConnectException; import java.net.MalformedURLException; import java.net.PasswordAuthentication; +import java.net.SocketException; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -49,6 +51,7 @@ import mage.interfaces.callback.ClientCallback; import mage.utils.CompressUtil; import mage.view.*; import org.apache.log4j.Logger; +import org.jboss.remoting.CannotConnectException; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; import org.jboss.remoting.ConnectionValidator; @@ -182,11 +185,28 @@ public class Session { client.showMessage("Unable to connect to server. " + ex.getMessage()); } // TODO: download client that matches server version + } catch (CannotConnectException ex) { + if (!canceled) { + Throwable t = ex.getCause(); + String message = ""; + while (t != null) { + if (t instanceof ConnectException) { + message = "Server is likely offline."; + break; + } + if (t instanceof SocketException) { + message = "Check your internet connection."; + break; + } + t = t.getCause(); + } + client.showMessage("Unable to connect to server. " + message); + } } catch (Throwable t) { logger.fatal("Unable to connect to server - ", t); if (!canceled) { disconnect(false); - client.showMessage("Unable to connect to server. " + t.getMessage()); + client.showMessage("Unable to connect to server. " + t.getMessage()); } } return false;