mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-10-03 09:07:33 +02:00
Added BentoBox#logStacktrace(Throwable)
This commit is contained in:
parent
d5750ca509
commit
a1d8c69556
@ -2,6 +2,7 @@ package world.bentobox.bentobox;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
@ -347,6 +348,16 @@ public class BentoBox extends JavaPlugin {
|
||||
getLogger().severe(() -> error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the stacktrace of a Throwable that was thrown by an error.
|
||||
* It should be used preferably instead of {@link Throwable#printStackTrace()} as it does not risk exposing sensitive information.
|
||||
* @param throwable the Throwable that was thrown by an error.
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public void logStacktrace(@NonNull Throwable throwable) {
|
||||
logError(ExceptionUtils.getStackTrace(throwable));
|
||||
}
|
||||
|
||||
public void logWarning(String warning) {
|
||||
getLogger().warning(() -> warning);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -39,8 +40,8 @@ public class GitHubConnector {
|
||||
contributorData = getData("contributors");
|
||||
releasesData = getData("releases");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
// TODO better logging and do not override data instead
|
||||
BentoBox.getInstance().logStacktrace(e);
|
||||
// TODO do not override data instead
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ public class AddonsManager {
|
||||
addon.setState(Addon.State.ERROR);
|
||||
plugin.logError("Skipping " + addon.getDescription().getName() + " due to an unhandled exception...");
|
||||
// Send stacktrace, required for addon development
|
||||
plugin.logError(ExceptionUtils.getStackTrace(throwable));
|
||||
plugin.logStacktrace(throwable);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user