Error handle

This commit is contained in:
2024-08-01 13:30:28 +02:00
parent 8e73544d27
commit 86495716e5

View File

@@ -50,6 +50,12 @@ public class Main {
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 401) {
System.err.println("Invalid credentials ! Pleas try again (defaults credentials could help)");
System.exit(1);
}
JSONObject responseObject = new JSONObject(response.body());
String token = responseObject.optString("token");