1
0
mirror of https://github.com/SKCraft/Launcher.git synced 2024-11-27 12:46:22 +01:00

Clean up error reporting for Minecraft API authentication

This commit is contained in:
Henry Le Grys 2021-02-16 22:16:42 +00:00
parent ff12d154c8
commit 8eb66d4c67
2 changed files with 14 additions and 13 deletions

View File

@ -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();
if (request.getResponseCode() == 200) {
return request.returnContent().asJson(McProfileResponse.class);
} else {
McServicesError error = request.returnContent().asJson(McServicesError.class);
.execute()
.expectResponseCodeOr(200, req -> {
McServicesError error = req.returnContent().asJson(McServicesError.class);
if (error.getError().equals("NOT_FOUND")) {
throw new AuthenticationException("No Minecraft profile",
return 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);
}
}

View File

@ -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