diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/microsoft/Msa.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/microsoft/Msa.java index 59609d08..c2349a7d 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/microsoft/Msa.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/microsoft/Msa.java @@ -306,9 +306,34 @@ public class Msa { } private static void throwResponseError(HttpURLConnection conn) throws IOException { + String otherErrStr = ""; String errStr = Tools.read(conn.getErrorStream()); // Log.i("MicroAuth","Error code: " + conn.getResponseCode() + ": " + conn.getResponseMessage() + "\n" + errStr); - throw new RuntimeException("MSA Error: " + conn.getResponseCode() + ": " + conn.getResponseMessage() + ", error stream:\n" + errStr); + +// it seems already handled by the demo mode.. +/* + if (errStr.contains("NOT_FOUND") && + errStr.contains("The server has not found anything matching the request URI")) + { + // TODO localize this + otherErrStr = "It seems that this Microsoft Account does not own the game. Make sure that you have bought/migrated to your Microsoft account."; + } else { +*/ + try { + JSONObject jo = new JSONObject(errStr); + switch ((int)(jo.getLong("XErr") - 2148916230l)) { + case 8: // AddChildToFamily + otherErrStr = "This account is under 18 and needs to be added to a Family by an adult before proceed."; + break; + case 3: // CreateAccount + otherErrStr = "The account isn't created yet."; + break; + } + } catch (Throwable th) { // not a JSON? + } + //} + + throw new RuntimeException(otherErrStr + "\n\nMSA Error: " + conn.getResponseCode() + ": " + conn.getResponseMessage() + ", error stream:\n" + errStr); } }