improved cannot connect error message

This commit is contained in:
BetaSteward 2011-10-30 21:15:14 -04:00
parent a004ced17d
commit 10e1469cfd

View file

@ -29,8 +29,10 @@
package mage.remote; package mage.remote;
import java.net.Authenticator; import java.net.Authenticator;
import java.net.ConnectException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.PasswordAuthentication; import java.net.PasswordAuthentication;
import java.net.SocketException;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -49,6 +51,7 @@ import mage.interfaces.callback.ClientCallback;
import mage.utils.CompressUtil; import mage.utils.CompressUtil;
import mage.view.*; import mage.view.*;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.jboss.remoting.CannotConnectException;
import org.jboss.remoting.Client; import org.jboss.remoting.Client;
import org.jboss.remoting.ConnectionListener; import org.jboss.remoting.ConnectionListener;
import org.jboss.remoting.ConnectionValidator; import org.jboss.remoting.ConnectionValidator;
@ -182,6 +185,23 @@ public class Session {
client.showMessage("Unable to connect to server. " + ex.getMessage()); client.showMessage("Unable to connect to server. " + ex.getMessage());
} }
// TODO: download client that matches server version // 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) { } catch (Throwable t) {
logger.fatal("Unable to connect to server - ", t); logger.fatal("Unable to connect to server - ", t);
if (!canceled) { if (!canceled) {