From 2599839fad5518fa79d1c1358ea50dcb33846fb8 Mon Sep 17 00:00:00 2001 From: tastybento Date: Thu, 7 Feb 2019 08:10:45 -0800 Subject: [PATCH] Shifted exception logging to logger. These are really needed if you are writing an addon otherwise you are blind to any reasons for an error. --- .../world/bentobox/bentobox/api/configuration/Config.java | 5 ++++- .../world/bentobox/bentobox/managers/AddonsManager.java | 8 +++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/api/configuration/Config.java b/src/main/java/world/bentobox/bentobox/api/configuration/Config.java index a769fa4a6..d4d8ed688 100644 --- a/src/main/java/world/bentobox/bentobox/api/configuration/Config.java +++ b/src/main/java/world/bentobox/bentobox/api/configuration/Config.java @@ -6,7 +6,9 @@ import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; +import org.apache.commons.lang.exception.ExceptionUtils; import org.eclipse.jdt.annotation.Nullable; + import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.database.AbstractDatabaseHandler; @@ -63,7 +65,8 @@ public class Config { } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | ClassNotFoundException | IntrospectionException | NoSuchMethodException | SecurityException e) { logger.severe(() -> "Could not load config object! " + e.getMessage()); - e.printStackTrace(); + // Required for debugging + logger.severe(ExceptionUtils.getStackTrace(e)); } return null; diff --git a/src/main/java/world/bentobox/bentobox/managers/AddonsManager.java b/src/main/java/world/bentobox/bentobox/managers/AddonsManager.java index ff0628c7a..e4c4a6e7f 100644 --- a/src/main/java/world/bentobox/bentobox/managers/AddonsManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/AddonsManager.java @@ -17,6 +17,7 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.stream.Collectors; +import org.apache.commons.lang.exception.ExceptionUtils; import org.bukkit.Bukkit; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; @@ -177,11 +178,8 @@ public class AddonsManager { addon.setState(Addon.State.ERROR); plugin.logError("Skipping " + addon.getDescription().getName() + " due to an unhandled exception..."); plugin.logError("STACKTRACE: " + throwable.getClass().getSimpleName() + " - " + throwable.getMessage() + " - " + throwable.getCause()); - throwable.printStackTrace(); - if (plugin.getConfig().getBoolean("debug")) { - plugin.logDebug(throwable.toString()); - plugin.logDebug(throwable.getStackTrace()); - } + // Required for addon development + plugin.logError(ExceptionUtils.getStackTrace(throwable)); } /**