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.
This commit is contained in:
tastybento 2019-02-07 08:10:45 -08:00
parent da21aa8c00
commit 2599839fad
2 changed files with 7 additions and 6 deletions

View File

@ -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<T> {
} 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;

View File

@ -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));
}
/**