From e9a4ad0869e840af756426a4bde76afe73c85cc4 Mon Sep 17 00:00:00 2001 From: Seb Date: Tue, 19 Apr 2022 21:00:18 +0100 Subject: [PATCH] refac(service): Added proper error logging to XP card getter (#87) --- .../de/voidtech/gerald/service/ExperienceService.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/voidtech/gerald/service/ExperienceService.java b/src/main/java/de/voidtech/gerald/service/ExperienceService.java index cd67f694..89037962 100644 --- a/src/main/java/de/voidtech/gerald/service/ExperienceService.java +++ b/src/main/java/de/voidtech/gerald/service/ExperienceService.java @@ -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; @@ -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, @@ -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) {