diff --git a/launcher/src/main/java/com/skcraft/launcher/auth/microsoft/MinecraftServicesAuthorizer.java b/launcher/src/main/java/com/skcraft/launcher/auth/microsoft/MinecraftServicesAuthorizer.java index 94062f7..1f8bc80 100644 --- a/launcher/src/main/java/com/skcraft/launcher/auth/microsoft/MinecraftServicesAuthorizer.java +++ b/launcher/src/main/java/com/skcraft/launcher/auth/microsoft/MinecraftServicesAuthorizer.java @@ -28,21 +28,21 @@ public class MinecraftServicesAuthorizer { public static McProfileResponse getUserProfile(McAuthResponse auth) throws IOException, InterruptedException, AuthenticationException { - HttpRequest request = HttpRequest.get(MC_SERVICES_PROFILE) + return HttpRequest.get(MC_SERVICES_PROFILE) .header("Authorization", auth.getAuthorization()) - .execute(); + .execute() + .expectResponseCodeOr(200, req -> { + McServicesError error = req.returnContent().asJson(McServicesError.class); - if (request.getResponseCode() == 200) { - return request.returnContent().asJson(McProfileResponse.class); - } else { - McServicesError error = request.returnContent().asJson(McServicesError.class); + if (error.getError().equals("NOT_FOUND")) { + return new AuthenticationException("No Minecraft profile", + SharedLocale.tr("login.minecraftNotOwnedError")); + } - if (error.getError().equals("NOT_FOUND")) { - throw new AuthenticationException("No Minecraft profile", - SharedLocale.tr("login.minecraftNotOwnedError")); - } - - throw new AuthenticationException(error.getErrorMessage()); - } + return new AuthenticationException(error.getErrorMessage(), + SharedLocale.tr("login.minecraft.error", error.getErrorMessage())); + }) + .returnContent() + .asJson(McProfileResponse.class); } } diff --git a/launcher/src/main/resources/com/skcraft/launcher/lang/Launcher.properties b/launcher/src/main/resources/com/skcraft/launcher/lang/Launcher.properties index 04592b1..085d65e 100644 --- a/launcher/src/main/resources/com/skcraft/launcher/lang/Launcher.properties +++ b/launcher/src/main/resources/com/skcraft/launcher/lang/Launcher.properties @@ -116,6 +116,7 @@ login.xbox.noXboxAccount=That account does not have an Xbox account associated! login.xbox.isChild=The account is a child (under 18) and cannot proceed unless it is part of a Family. login.xbox.unknown=An unknown error occurred while logging in with Xbox (XErr {0}) login.xbox.errorMessage=An unknown error occurred while logging in with Xbox: {0} +login.minecraft.error=An error occurred while authorizing with Minecraft services: {0} console.title=Messages and Errors console.launcherConsoleTitle=Launcher Messages