mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
improved cannot connect error message
This commit is contained in:
parent
a004ced17d
commit
10e1469cfd
1 changed files with 21 additions and 1 deletions
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue