feat: more response codes and default case
This commit is contained in:
parent
11fe303bc0
commit
4d1c6898ca
1 changed files with 9 additions and 1 deletions
|
@ -71,6 +71,10 @@ public class MojangAPI {
|
||||||
con.setRequestMethod("GET");
|
con.setRequestMethod("GET");
|
||||||
|
|
||||||
switch (con.getResponseCode()) {
|
switch (con.getResponseCode()) {
|
||||||
|
case 400 -> {
|
||||||
|
instance.getLogger().warning("Failed to parse request: Invalid Name");
|
||||||
|
return getErrorObject();
|
||||||
|
}
|
||||||
case 429 -> {
|
case 429 -> {
|
||||||
instance.getLogger().warning("Failed to parse request! The connection is throttled.");
|
instance.getLogger().warning("Failed to parse request! The connection is throttled.");
|
||||||
return getErrorObject();
|
return getErrorObject();
|
||||||
|
@ -87,10 +91,14 @@ public class MojangAPI {
|
||||||
final JsonElement jsonElt = JsonParser.parseString(builder.toString());
|
final JsonElement jsonElt = JsonParser.parseString(builder.toString());
|
||||||
return jsonElt.getAsJsonObject();
|
return jsonElt.getAsJsonObject();
|
||||||
} catch (JsonParseException | IllegalStateException exception) {
|
} catch (JsonParseException | IllegalStateException exception) {
|
||||||
instance.getLogger().warning("Failed to parse request (" + parametrizedUrl + ")! Does the username exists?");
|
instance.getLogger().warning("Failed to parse request (" + parametrizedUrl + ")!");
|
||||||
return getErrorObject();
|
return getErrorObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
default -> {
|
||||||
|
instance.getLogger().warning("Unhandled response code from Mojang: " + con.getResponseCode());
|
||||||
|
return getErrorObject();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue