Skip to content

Commit

Permalink
refac(service): Added proper error logging to XP card getter (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
Seb committed Apr 19, 2022
1 parent ba81384 commit e9a4ad0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main/java/de/voidtech/gerald/service/ExperienceService.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package main.java.de.voidtech.gerald.service;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.List;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.xml.bind.DatatypeConverter;

Expand Down Expand Up @@ -38,6 +39,7 @@ public class ExperienceService {
@Autowired
private GeraldConfig config;

private static final Logger LOGGER = Logger.getLogger(ExperienceService.class.getName());
private static final int EXPERIENCE_DELAY = 0; //Delay between incrementing XP in seconds

public byte[] getExperienceCard(String avatarURL, long xpAchieved, long xpNeeded,
Expand All @@ -53,14 +55,10 @@ public byte[] getExperienceCard(String avatarURL, long xpAchieved, long xpNeeded
String response = Jsoup.connect(url.toString()).get().toString().split(",")[1];
byte[] imageBytes = DatatypeConverter.parseBase64Binary(response);
return imageBytes;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
LOGGER.log(Level.SEVERE, e.getMessage());
}

return null;

}

public Experience getUserExperience(String userID, long serverID) {
Expand Down

0 comments on commit e9a4ad0

Please sign in to comment.