connection: added error message for failed connection on wrongly configured server (related to #12768, #6197)

This commit is contained in:
Oleg Agafonov 2024-09-13 14:54:44 +04:00
parent 45ded61d6f
commit 350b41391a

View file

@ -505,6 +505,7 @@ public class SessionImpl implements Session {
} }
if (t.toString().contains("to make private")) { if (t.toString().contains("to make private")) {
// example: Unable to make private void java.io.ObjectOutputStream.clear() accessible: module java.base does not "opens java.io" to unnamed module // example: Unable to make private void java.io.ObjectOutputStream.clear() accessible: module java.base does not "opens java.io" to unnamed module
// TODO: show that error as error dialog, so users can report to github
message = "Wrong java version - check your client running scripts and params." + message; message = "Wrong java version - check your client running scripts and params." + message;
break; break;
} }
@ -512,6 +513,17 @@ public class SessionImpl implements Session {
message = '\n' + t.getCause().getMessage() + message; message = '\n' + t.getCause().getMessage() + message;
logger.debug(t.getCause().getMessage()); logger.debug(t.getCause().getMessage());
} }
if (t.getCause() == null) {
// last chance to find real reason
if (Arrays.stream(t.getStackTrace()).anyMatch(stack -> Objects.equals("ObjectInputStream.java", stack.getFileName()))) {
// how-to fix: non-standard java version require additional params, see https://github.com/magefree/mage/issues/12768
// TODO: show that error as error dialog, so users can report to github
message = "Wrong client-server protocol - report to server's admin about compatibility problems. " + message;
break;
}
}
t = t.getCause(); t = t.getCause();
} }
client.showMessage("Unable connect to server. " + message); client.showMessage("Unable connect to server. " + message);