mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-01 14:07:54 +01:00
Added more context to errors (#1450)
* Improved Extension errors * Removed scary reflective operation exception * Additional context to SQL Exceptions * Added error context to Listeners * Added error context to most error logging places * Ignore cyclomatic complexity of DBOpException Adds context to almost all error logging situations, except those where it is unknown, or to commands that are being refactored on another branch. Close #1245
This commit is contained in:
parent
9cd0bcd369
commit
93dc1bbb9e
@ -116,4 +116,15 @@ public final class Request {
|
|||||||
public Request omitFirstInPath() {
|
public Request omitFirstInPath() {
|
||||||
return new Request(method, path.omitFirst(), query, user, headers);
|
return new Request(method, path.omitFirst(), query, user, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Request{" +
|
||||||
|
"method='" + method + '\'' +
|
||||||
|
", path=" + path +
|
||||||
|
", query=" + query +
|
||||||
|
", user=" + user +
|
||||||
|
", headers=" + headers +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
@ -119,4 +119,11 @@ public final class URIPath {
|
|||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "URIPath{" +
|
||||||
|
"path='" + path + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,4 +94,11 @@ public final class URIQuery {
|
|||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "URIQuery{" +
|
||||||
|
"byKey=" + byKey +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,4 +59,13 @@ public final class WebUser {
|
|||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WebUser{" +
|
||||||
|
"playerName='" + playerName + '\'' +
|
||||||
|
", username='" + username + '\'' +
|
||||||
|
", permissions=" + permissions +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.addons.placeholderapi;
|
|||||||
|
|
||||||
import com.djrapitops.plan.PlanSystem;
|
import com.djrapitops.plan.PlanSystem;
|
||||||
import com.djrapitops.plan.placeholder.PlanPlaceholders;
|
import com.djrapitops.plan.placeholder.PlanPlaceholders;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plan.version.VersionChecker;
|
import com.djrapitops.plan.version.VersionChecker;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
@ -92,7 +93,7 @@ public class PlanPlaceholderExtension extends PlaceholderExpansion {
|
|||||||
|
|
||||||
return value;
|
return value;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.WARN, getClass(), e);
|
errorLogger.log(L.WARN, e, ErrorContext.builder().whatToDo("Report this").related("Placeholder Request", params).build());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ package com.djrapitops.plan.gathering.listeners.bukkit;
|
|||||||
import com.djrapitops.plan.gathering.afk.AFKTracker;
|
import com.djrapitops.plan.gathering.afk.AFKTracker;
|
||||||
import com.djrapitops.plan.settings.Permissions;
|
import com.djrapitops.plan.settings.Permissions;
|
||||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -79,7 +80,7 @@ public class BukkitAFKListener implements Listener {
|
|||||||
|
|
||||||
AFK_TRACKER.performedAction(uuid, time);
|
AFK_TRACKER.performedAction(uuid, time);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import com.djrapitops.plan.gathering.cache.NicknameCache;
|
|||||||
import com.djrapitops.plan.identification.ServerInfo;
|
import com.djrapitops.plan.identification.ServerInfo;
|
||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction;
|
import com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -66,7 +67,7 @@ public class ChatListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
actOnChatEvent(event);
|
actOnChatEvent(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import com.djrapitops.plan.gathering.domain.Session;
|
|||||||
import com.djrapitops.plan.processing.Processing;
|
import com.djrapitops.plan.processing.Processing;
|
||||||
import com.djrapitops.plan.processing.processors.player.MobKillProcessor;
|
import com.djrapitops.plan.processing.processors.player.MobKillProcessor;
|
||||||
import com.djrapitops.plan.processing.processors.player.PlayerKillProcessor;
|
import com.djrapitops.plan.processing.processors.player.PlayerKillProcessor;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -80,7 +81,7 @@ public class DeathEventListener implements Listener {
|
|||||||
UUID uuid = dead instanceof Player ? dead.getUniqueId() : null;
|
UUID uuid = dead instanceof Player ? dead.getUniqueId() : null;
|
||||||
handleKill(time, uuid, killerEntity);
|
handleKill(time, uuid, killerEntity);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event, dead).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import com.djrapitops.plan.identification.ServerInfo;
|
|||||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -67,7 +68,7 @@ public class GameModeChangeListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
actOnEvent(event);
|
actOnEvent(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event, event.getPlayer().getGameMode() + "->" + event.getNewGameMode()).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import com.djrapitops.plan.settings.config.paths.ExportSettings;
|
|||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
import com.djrapitops.plan.storage.database.Database;
|
import com.djrapitops.plan.storage.database.Database;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.*;
|
import com.djrapitops.plan.storage.database.transactions.events.*;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -107,7 +108,7 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
dbSystem.getDatabase().executeTransaction(new BanStatusTransaction(playerUUID, () -> banned));
|
dbSystem.getDatabase().executeTransaction(new BanStatusTransaction(playerUUID, () -> banned));
|
||||||
dbSystem.getDatabase().executeTransaction(new OperatorStatusTransaction(playerUUID, operator));
|
dbSystem.getDatabase().executeTransaction(new OperatorStatusTransaction(playerUUID, operator));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event, event.getResult()).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +133,7 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
|
|
||||||
dbSystem.getDatabase().executeTransaction(new KickStoreTransaction(uuid));
|
dbSystem.getDatabase().executeTransaction(new KickStoreTransaction(uuid));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +142,7 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
actOnJoinEvent(event);
|
actOnJoinEvent(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +206,7 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
actOnQuitEvent(event);
|
actOnQuitEvent(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import com.djrapitops.plan.identification.ServerInfo;
|
|||||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -59,7 +60,7 @@ public class WorldChangeListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
actOnEvent(event);
|
actOnEvent(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,8 +89,7 @@ public class BukkitPingCounter extends AbsRunnable implements Listener {
|
|||||||
} catch (NoSuchMethodException | IllegalAccessException | NoSuchFieldException reflectiveEx) {
|
} catch (NoSuchMethodException | IllegalAccessException | NoSuchFieldException reflectiveEx) {
|
||||||
Logger.getGlobal().log(
|
Logger.getGlobal().log(
|
||||||
Level.WARNING,
|
Level.WARNING,
|
||||||
"Plan: Reflective exception in static initializer of PingCountTimer",
|
"Plan: Could not register Ping counter due to " + reflectiveEx
|
||||||
reflectiveEx
|
|
||||||
);
|
);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
Logger.getGlobal().log(
|
Logger.getGlobal().log(
|
||||||
|
@ -34,6 +34,7 @@ import com.djrapitops.plan.storage.database.DBSystem;
|
|||||||
import com.djrapitops.plan.storage.database.Database;
|
import com.djrapitops.plan.storage.database.Database;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.GeoInfoStoreTransaction;
|
import com.djrapitops.plan.storage.database.transactions.events.GeoInfoStoreTransaction;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
|
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -92,7 +93,7 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
actOnLogin(event);
|
actOnLogin(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.WARN, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +143,7 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
actOnLogout(event);
|
actOnLogout(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.WARN, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +180,7 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
actOnServerSwitch(event);
|
actOnServerSwitch(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.WARN, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ import com.djrapitops.plan.settings.SettingsSvc;
|
|||||||
import com.djrapitops.plan.settings.locale.LocaleSystem;
|
import com.djrapitops.plan.settings.locale.LocaleSystem;
|
||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
import com.djrapitops.plan.storage.file.PlanFiles;
|
import com.djrapitops.plan.storage.file.PlanFiles;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plan.version.VersionChecker;
|
import com.djrapitops.plan.version.VersionChecker;
|
||||||
import com.djrapitops.plugin.benchmarking.Benchmark;
|
import com.djrapitops.plugin.benchmarking.Benchmark;
|
||||||
@ -222,7 +223,7 @@ public class PlanSystem implements SubSystem {
|
|||||||
system.disable();
|
system.disable();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.WARN, this.getClass(), e);
|
errorLogger.log(L.WARN, e, ErrorContext.builder().related("Disabling PlanSystem: " + system).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public class ExportScheduler {
|
|||||||
private void schedulePlayersPageExport() {
|
private void schedulePlayersPageExport() {
|
||||||
long period = TimeAmount.toTicks(config.get(ExportSettings.EXPORT_PERIOD), TimeUnit.MILLISECONDS);
|
long period = TimeAmount.toTicks(config.get(ExportSettings.EXPORT_PERIOD), TimeUnit.MILLISECONDS);
|
||||||
taskSystem.registerTask("Players page export",
|
taskSystem.registerTask("Players page export",
|
||||||
new ExportTask(exporter, Exporter::exportPlayersPage, logger, errorLogger)
|
new ExportTask(exporter, Exporter::exportPlayersPage, errorLogger)
|
||||||
).runTaskTimerAsynchronously(0L, period);
|
).runTaskTimerAsynchronously(0L, period);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ public class ExportScheduler {
|
|||||||
|
|
||||||
Optional<Server> proxy = servers.stream().filter(Server::isProxy).findFirst();
|
Optional<Server> proxy = servers.stream().filter(Server::isProxy).findFirst();
|
||||||
proxy.ifPresent(mainServer -> taskSystem.registerTask("Network export",
|
proxy.ifPresent(mainServer -> taskSystem.registerTask("Network export",
|
||||||
new ExportTask(exporter, exporter -> exporter.exportServerPage(mainServer), logger, errorLogger))
|
new ExportTask(exporter, exporter -> exporter.exportServerPage(mainServer), errorLogger))
|
||||||
.runTaskTimerAsynchronously(0L, period)
|
.runTaskTimerAsynchronously(0L, period)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ public class ExportScheduler {
|
|||||||
new ExportTask(exporter, same -> {
|
new ExportTask(exporter, same -> {
|
||||||
same.exportServerPage(server);
|
same.exportServerPage(server);
|
||||||
same.exportServerJSON(server);
|
same.exportServerJSON(server);
|
||||||
}, logger, errorLogger))
|
}, errorLogger))
|
||||||
.runTaskTimerAsynchronously(offset * offsetMultiplier, period);
|
.runTaskTimerAsynchronously(offset * offsetMultiplier, period);
|
||||||
offsetMultiplier++;
|
offsetMultiplier++;
|
||||||
}
|
}
|
||||||
|
@ -19,27 +19,24 @@ package com.djrapitops.plan.delivery.export;
|
|||||||
import com.djrapitops.plan.exceptions.ExportException;
|
import com.djrapitops.plan.exceptions.ExportException;
|
||||||
import com.djrapitops.plan.exceptions.database.DBOpException;
|
import com.djrapitops.plan.exceptions.database.DBOpException;
|
||||||
import com.djrapitops.plan.utilities.java.ThrowingConsumer;
|
import com.djrapitops.plan.utilities.java.ThrowingConsumer;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
|
||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
|
|
||||||
public class ExportTask extends AbsRunnable {
|
public class ExportTask extends AbsRunnable {
|
||||||
|
|
||||||
private final Exporter exporter;
|
private final Exporter exporter;
|
||||||
private final ThrowingConsumer<Exporter, ExportException> exportAction;
|
private final ThrowingConsumer<Exporter, ExportException> exportAction;
|
||||||
private final PluginLogger logger;
|
|
||||||
private final ErrorLogger errorLogger;
|
private final ErrorLogger errorLogger;
|
||||||
|
|
||||||
public ExportTask(
|
public ExportTask(
|
||||||
Exporter exporter,
|
Exporter exporter,
|
||||||
ThrowingConsumer<Exporter, ExportException> exportAction,
|
ThrowingConsumer<Exporter, ExportException> exportAction,
|
||||||
PluginLogger logger,
|
|
||||||
ErrorLogger errorLogger
|
ErrorLogger errorLogger
|
||||||
) {
|
) {
|
||||||
this.exporter = exporter;
|
this.exporter = exporter;
|
||||||
this.exportAction = exportAction;
|
this.exportAction = exportAction;
|
||||||
this.logger = logger;
|
|
||||||
this.errorLogger = errorLogger;
|
this.errorLogger = errorLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,22 +45,26 @@ public class ExportTask extends AbsRunnable {
|
|||||||
try {
|
try {
|
||||||
exportAction.accept(exporter);
|
exportAction.accept(exporter);
|
||||||
} catch (ExportException e) {
|
} catch (ExportException e) {
|
||||||
errorLogger.log(L.WARN, this.getClass(), e);
|
errorLogger.log(L.WARN, e, ErrorContext.builder().related("Export task run").build());
|
||||||
} catch (DBOpException dbException) {
|
} catch (DBOpException dbException) {
|
||||||
handleDBException(dbException);
|
handleDBException(dbException);
|
||||||
} catch (Exception | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
|
} catch (Exception | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
|
||||||
logger.error("Export Task Disabled due to error, reload Plan to re-enable.");
|
errorLogger.log(L.ERROR, e, ErrorContext.builder()
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
.whatToDo("Export Task Disabled due to error - reload Plan to re-enable.")
|
||||||
|
.related("Export task run").build());
|
||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleDBException(DBOpException dbException) {
|
private void handleDBException(DBOpException dbException) {
|
||||||
logger.error("Export Task Disabled due to database error, reload Plan to re-enable.");
|
|
||||||
if (dbException.getMessage().contains("closed")) {
|
if (dbException.getMessage().contains("closed")) {
|
||||||
logger.warn("(Error was caused by database closing, so this error can possibly be ignored.)");
|
errorLogger.log(L.ERROR, dbException, ErrorContext.builder()
|
||||||
|
.whatToDo("Export Task Disabled due to error - database is closing, so this error can be ignored.).")
|
||||||
|
.related("Export task run").build());
|
||||||
} else {
|
} else {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), dbException);
|
errorLogger.log(L.ERROR, dbException, ErrorContext.builder()
|
||||||
|
.whatToDo("Export Task Disabled due to error - reload Plan to re-enable.")
|
||||||
|
.related("Export task run").build());
|
||||||
}
|
}
|
||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import com.djrapitops.plan.identification.ServerInfo;
|
|||||||
import com.djrapitops.plan.identification.properties.ServerProperties;
|
import com.djrapitops.plan.identification.properties.ServerProperties;
|
||||||
import com.djrapitops.plan.storage.database.Database;
|
import com.djrapitops.plan.storage.database.Database;
|
||||||
import com.djrapitops.plan.storage.file.ResourceCache;
|
import com.djrapitops.plan.storage.file.ResourceCache;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plan.version.VersionChecker;
|
import com.djrapitops.plan.version.VersionChecker;
|
||||||
import com.djrapitops.plugin.benchmarking.Benchmark;
|
import com.djrapitops.plugin.benchmarking.Benchmark;
|
||||||
@ -135,7 +136,7 @@ public class DebugPage implements Page {
|
|||||||
}
|
}
|
||||||
content.append("</pre>");
|
content.append("</pre>");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.WARN, this.getClass(), e);
|
errorLogger.log(L.WARN, e, ErrorContext.builder().related("/debug page access, resource cache").build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +152,7 @@ public class DebugPage implements Page {
|
|||||||
}
|
}
|
||||||
content.append("</pre>");
|
content.append("</pre>");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.WARN, this.getClass(), e);
|
errorLogger.log(L.WARN, e, ErrorContext.builder().related("/debug page access, JSON cache").build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +173,7 @@ public class DebugPage implements Page {
|
|||||||
}
|
}
|
||||||
content.append("</pre>");
|
content.append("</pre>");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.WARN, this.getClass(), e);
|
errorLogger.log(L.WARN, e, ErrorContext.builder().related("/debug page access, Session cache").build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import com.djrapitops.plan.settings.locale.Locale;
|
|||||||
import com.djrapitops.plan.settings.locale.lang.PluginLang;
|
import com.djrapitops.plan.settings.locale.lang.PluginLang;
|
||||||
import com.djrapitops.plan.storage.file.PlanFiles;
|
import com.djrapitops.plan.storage.file.PlanFiles;
|
||||||
import com.djrapitops.plan.storage.file.Resource;
|
import com.djrapitops.plan.storage.file.Resource;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -145,7 +146,9 @@ public class ResourceSvc implements ResourceService {
|
|||||||
return getOrWriteCustomized(fileName, source);
|
return getOrWriteCustomized(fileName, source);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
errorLogger.log(L.WARN, getClass(), e.getCause());
|
errorLogger.log(L.WARN, e, ErrorContext.builder()
|
||||||
|
.whatToDo("Report this or provide " + fileName + " in " + files.getCustomizationDirectory())
|
||||||
|
.related("Fetching resource", "Of: " + pluginName, fileName).build());
|
||||||
}
|
}
|
||||||
// Return original by default
|
// Return original by default
|
||||||
return source.get();
|
return source.get();
|
||||||
|
@ -19,6 +19,7 @@ package com.djrapitops.plan.delivery.webserver;
|
|||||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||||
import com.djrapitops.plan.settings.config.paths.PluginSettings;
|
import com.djrapitops.plan.settings.config.paths.PluginSettings;
|
||||||
import com.djrapitops.plan.settings.config.paths.WebserverSettings;
|
import com.djrapitops.plan.settings.config.paths.WebserverSettings;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -73,9 +74,10 @@ public class NonProxyWebserverDisableChecker implements Runnable {
|
|||||||
config.set(WebserverSettings.DISABLED, true);
|
config.set(WebserverSettings.DISABLED, true);
|
||||||
config.save();
|
config.save();
|
||||||
logger.warn("Note: Set '" + WebserverSettings.DISABLED.getPath() + "' to true");
|
logger.warn("Note: Set '" + WebserverSettings.DISABLED.getPath() + "' to true");
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
errorLogger.log(L.WARN, this.getClass(), e);
|
errorLogger.log(L.WARN, e, ErrorContext.builder()
|
||||||
|
.whatToDo("Set '" + WebserverSettings.DISABLED.getPath() + "' to true manually.")
|
||||||
|
.related("Disabling webserver in config setting", WebserverSettings.DISABLED.getPath()).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -31,6 +31,7 @@ import com.djrapitops.plan.settings.config.PlanConfig;
|
|||||||
import com.djrapitops.plan.settings.config.paths.PluginSettings;
|
import com.djrapitops.plan.settings.config.paths.PluginSettings;
|
||||||
import com.djrapitops.plan.settings.config.paths.WebserverSettings;
|
import com.djrapitops.plan.settings.config.paths.WebserverSettings;
|
||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -99,7 +100,10 @@ public class RequestHandler implements HttpHandler {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (config.isTrue(PluginSettings.DEV_MODE)) {
|
if (config.isTrue(PluginSettings.DEV_MODE)) {
|
||||||
logger.warn("THIS ERROR IS ONLY LOGGED IN DEV MODE:");
|
logger.warn("THIS ERROR IS ONLY LOGGED IN DEV MODE:");
|
||||||
errorLogger.log(L.WARN, this.getClass(), e);
|
errorLogger.log(L.WARN, e, ErrorContext.builder()
|
||||||
|
.whatToDo("THIS ERROR IS ONLY LOGGED IN DEV MODE")
|
||||||
|
.related(exchange.getRequestMethod(), exchange.getRemoteAddress(), exchange.getRequestHeaders(), exchange.getResponseHeaders(), exchange.getRequestURI())
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
exchange.close();
|
exchange.close();
|
||||||
|
@ -31,6 +31,7 @@ import com.djrapitops.plan.delivery.webserver.resolver.auth.*;
|
|||||||
import com.djrapitops.plan.delivery.webserver.resolver.json.RootJSONResolver;
|
import com.djrapitops.plan.delivery.webserver.resolver.json.RootJSONResolver;
|
||||||
import com.djrapitops.plan.exceptions.WebUserAuthException;
|
import com.djrapitops.plan.exceptions.WebUserAuthException;
|
||||||
import com.djrapitops.plan.exceptions.connection.ForbiddenException;
|
import com.djrapitops.plan.exceptions.connection.ForbiddenException;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import dagger.Lazy;
|
import dagger.Lazy;
|
||||||
@ -143,7 +144,7 @@ public class ResponseResolver {
|
|||||||
} catch (WebUserAuthException e) {
|
} catch (WebUserAuthException e) {
|
||||||
throw e; // Pass along
|
throw e; // Pass along
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(request).build());
|
||||||
return responseFactory.internalErrorResponse(e, request.getPath().asString());
|
return responseFactory.internalErrorResponse(e, request.getPath().asString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import com.djrapitops.plan.settings.config.paths.WebserverSettings;
|
|||||||
import com.djrapitops.plan.settings.locale.Locale;
|
import com.djrapitops.plan.settings.locale.Locale;
|
||||||
import com.djrapitops.plan.settings.locale.lang.PluginLang;
|
import com.djrapitops.plan.settings.locale.lang.PluginLang;
|
||||||
import com.djrapitops.plan.storage.file.PlanFiles;
|
import com.djrapitops.plan.storage.file.PlanFiles;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -145,7 +146,9 @@ public class WebServer implements SubSystem {
|
|||||||
.namingPattern("Plan WebServer Thread-%d")
|
.namingPattern("Plan WebServer Thread-%d")
|
||||||
.uncaughtExceptionHandler((thread, throwable) -> {
|
.uncaughtExceptionHandler((thread, throwable) -> {
|
||||||
if (config.isTrue(PluginSettings.DEV_MODE)) {
|
if (config.isTrue(PluginSettings.DEV_MODE)) {
|
||||||
errorLogger.log(L.WARN, WebServer.class, throwable);
|
errorLogger.log(L.WARN, throwable, ErrorContext.builder()
|
||||||
|
.whatToDo("THIS ERROR IS ONLY LOGGED IN DEV MODE")
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
}).build()
|
}).build()
|
||||||
);
|
);
|
||||||
@ -165,7 +168,7 @@ public class WebServer implements SubSystem {
|
|||||||
logger.error("Webserver failed to bind port: " + failedToBind.toString());
|
logger.error("Webserver failed to bind port: " + failedToBind.toString());
|
||||||
enabled = false;
|
enabled = false;
|
||||||
} catch (IllegalArgumentException | IllegalStateException | IOException e) {
|
} catch (IllegalArgumentException | IllegalStateException | IOException e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related("Trying to enable webserver", config.get(WebserverSettings.INTERNAL_IP) + ":" + port).build());
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,7 +186,9 @@ public class WebServer implements SubSystem {
|
|||||||
}
|
}
|
||||||
} catch (InvalidPathException e) {
|
} catch (InvalidPathException e) {
|
||||||
logger.error("WebServer: Could not find Keystore: " + e.getMessage());
|
logger.error("WebServer: Could not find Keystore: " + e.getMessage());
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder()
|
||||||
|
.whatToDo(e.getMessage() + ", Fix this path to point to a valid keystore file: " + keyStorePath)
|
||||||
|
.related(keyStorePath).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
char[] storepass = config.get(WebserverSettings.CERTIFICATE_STOREPASS).toCharArray();
|
char[] storepass = config.get(WebserverSettings.CERTIFICATE_STOREPASS).toCharArray();
|
||||||
@ -232,7 +237,7 @@ public class WebServer implements SubSystem {
|
|||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
} catch (KeyManagementException | NoSuchAlgorithmException e) {
|
} catch (KeyManagementException | NoSuchAlgorithmException e) {
|
||||||
logger.error(locale.getString(PluginLang.WEB_SERVER_FAIL_SSL_CONTEXT));
|
logger.error(locale.getString(PluginLang.WEB_SERVER_FAIL_SSL_CONTEXT));
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(keyStoreKind).build());
|
||||||
} catch (EOFException e) {
|
} catch (EOFException e) {
|
||||||
logger.error(locale.getString(PluginLang.WEB_SERVER_FAIL_EMPTY_FILE));
|
logger.error(locale.getString(PluginLang.WEB_SERVER_FAIL_EMPTY_FILE));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
@ -241,11 +246,12 @@ public class WebServer implements SubSystem {
|
|||||||
} catch (BindException e) {
|
} catch (BindException e) {
|
||||||
throw e; // Pass to above error handler
|
throw e; // Pass to above error handler
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("WebServer: " + e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(config.get(WebserverSettings.INTERNAL_IP) + ":" + port).build());
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
|
||||||
} catch (KeyStoreException | CertificateException | UnrecoverableKeyException e) {
|
} catch (KeyStoreException | CertificateException | UnrecoverableKeyException e) {
|
||||||
logger.error(locale.getString(PluginLang.WEB_SERVER_FAIL_STORE_LOAD));
|
logger.error(locale.getString(PluginLang.WEB_SERVER_FAIL_STORE_LOAD));
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder()
|
||||||
|
.whatToDo("Make sure the Certificate settings are correct / You can try remaking the keystore without -passin or -passout parameters.")
|
||||||
|
.related(keyStorePath).build());
|
||||||
}
|
}
|
||||||
return startSuccessful;
|
return startSuccessful;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Player Analytics (Plan).
|
||||||
|
*
|
||||||
|
* Plan is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Plan is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.djrapitops.plan.exceptions;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface ExceptionWithContext {
|
||||||
|
Optional<ErrorContext> getContext();
|
||||||
|
}
|
@ -16,14 +16,20 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.exceptions.database;
|
package com.djrapitops.plan.exceptions.database;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.exceptions.ExceptionWithContext;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runtime exception for wrapping database errors.
|
* Runtime exception for wrapping database errors.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public class DBOpException extends IllegalStateException {
|
public class DBOpException extends IllegalStateException implements ExceptionWithContext {
|
||||||
|
|
||||||
|
private ErrorContext context;
|
||||||
|
|
||||||
public DBOpException(String message) {
|
public DBOpException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
@ -33,8 +39,100 @@ public class DBOpException extends IllegalStateException {
|
|||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DBOpException forCause(String sql, SQLException e) {
|
public DBOpException(String message, Throwable cause, ErrorContext context) {
|
||||||
return new DBOpException("SQL Failed: " + sql + "; " + e.getMessage(), e);
|
super(message, cause);
|
||||||
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checkstyle.OFF: CyclomaticComplexity
|
||||||
|
|
||||||
|
public static DBOpException forCause(String sql, SQLException e) {
|
||||||
|
ErrorContext.Builder context = ErrorContext.builder();
|
||||||
|
int errorCode = e.getErrorCode();
|
||||||
|
context.related("Error code: " + errorCode)
|
||||||
|
.related(sql);
|
||||||
|
switch (errorCode) {
|
||||||
|
// SQLite Corrupt
|
||||||
|
case 10:
|
||||||
|
case 523:
|
||||||
|
context.related("SQL Corrupted")
|
||||||
|
.whatToDo("Your SQLite has corrupted. This can happen if .db-wal or .db-shm files get replaced mid operation. Restore database.db from backup.");
|
||||||
|
break;
|
||||||
|
// Syntax error codes
|
||||||
|
case 1054: // MySQL
|
||||||
|
case 1064:
|
||||||
|
case 1146:
|
||||||
|
case 42000: // H2
|
||||||
|
case 42001:
|
||||||
|
case 42101:
|
||||||
|
case 42102:
|
||||||
|
case 42111:
|
||||||
|
case 42112:
|
||||||
|
case 42121:
|
||||||
|
case 42122:
|
||||||
|
case 42132:
|
||||||
|
context.related("SQL Grammar error")
|
||||||
|
.whatToDo("Report this, there is an SQL grammar error.");
|
||||||
|
break;
|
||||||
|
// Type mismatch
|
||||||
|
case 20: // SQLite
|
||||||
|
context.related("SQL Type mismatch")
|
||||||
|
.whatToDo("Report this, there is an SQL Type mismatch.");
|
||||||
|
break;
|
||||||
|
// Duplicate key
|
||||||
|
case 1062:
|
||||||
|
case 23001:
|
||||||
|
case 23505:
|
||||||
|
context.related("Duplicate key")
|
||||||
|
.whatToDo("Report this, duplicate key exists in SQL.");
|
||||||
|
break;
|
||||||
|
// Constraint violation
|
||||||
|
case 19: // SQLite
|
||||||
|
case 275:
|
||||||
|
case 531:
|
||||||
|
case 787:
|
||||||
|
case 1043:
|
||||||
|
case 1299:
|
||||||
|
case 1555:
|
||||||
|
case 2579:
|
||||||
|
case 1811:
|
||||||
|
case 2067:
|
||||||
|
case 2323:
|
||||||
|
case 630: // MySQL
|
||||||
|
case 839:
|
||||||
|
case 840:
|
||||||
|
case 893:
|
||||||
|
case 1169:
|
||||||
|
case 1215:
|
||||||
|
case 1216:
|
||||||
|
case 1217:
|
||||||
|
case 1364:
|
||||||
|
case 1451:
|
||||||
|
case 1557:
|
||||||
|
case 22001: // H2
|
||||||
|
case 22003:
|
||||||
|
case 22012:
|
||||||
|
case 22018:
|
||||||
|
case 22025:
|
||||||
|
case 23000:
|
||||||
|
case 23002:
|
||||||
|
case 23502:
|
||||||
|
case 23506:
|
||||||
|
case 23507:
|
||||||
|
case 23513:
|
||||||
|
context.related("Constraint Violation")
|
||||||
|
.whatToDo("Report this, there is an SQL Constraint Violation.");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
context.related("Unknown SQL Error code");
|
||||||
|
}
|
||||||
|
return new DBOpException("SQL Failure: " + e.getMessage(), e, context.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checkstyle.ON: CyclomaticComplexity
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<ErrorContext> getContext() {
|
||||||
|
return Optional.ofNullable(context);
|
||||||
|
}
|
||||||
}
|
}
|
@ -23,12 +23,14 @@ import com.djrapitops.plan.exceptions.DataExtensionMethodCallException;
|
|||||||
import com.djrapitops.plan.extension.implementation.CallerImplementation;
|
import com.djrapitops.plan.extension.implementation.CallerImplementation;
|
||||||
import com.djrapitops.plan.extension.implementation.ExtensionRegister;
|
import com.djrapitops.plan.extension.implementation.ExtensionRegister;
|
||||||
import com.djrapitops.plan.extension.implementation.ExtensionWrapper;
|
import com.djrapitops.plan.extension.implementation.ExtensionWrapper;
|
||||||
|
import com.djrapitops.plan.extension.implementation.providers.MethodWrapper;
|
||||||
import com.djrapitops.plan.extension.implementation.providers.gathering.ProviderValueGatherer;
|
import com.djrapitops.plan.extension.implementation.providers.gathering.ProviderValueGatherer;
|
||||||
import com.djrapitops.plan.identification.ServerInfo;
|
import com.djrapitops.plan.identification.ServerInfo;
|
||||||
import com.djrapitops.plan.processing.Processing;
|
import com.djrapitops.plan.processing.Processing;
|
||||||
import com.djrapitops.plan.settings.config.ExtensionSettings;
|
import com.djrapitops.plan.settings.config.ExtensionSettings;
|
||||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -88,8 +90,14 @@ public class ExtensionSvc implements ExtensionService {
|
|||||||
try {
|
try {
|
||||||
extensionRegister.registerBuiltInExtensions(config.getExtensionSettings().getDisabled());
|
extensionRegister.registerBuiltInExtensions(config.getExtensionSettings().getDisabled());
|
||||||
} catch (IllegalStateException failedToRegisterOne) {
|
} catch (IllegalStateException failedToRegisterOne) {
|
||||||
logger.warn("One or more extensions failed to register, see suppressed exceptions (They can be disabled in Plan config).");
|
ErrorContext.Builder context = ErrorContext.builder()
|
||||||
errorLogger.log(L.WARN, ExtensionService.class, failedToRegisterOne);
|
.whatToDo("Report and/or disable the failed extensions. You can find the failed extensions in the error file.");
|
||||||
|
for (Throwable suppressedException : failedToRegisterOne.getSuppressed()) {
|
||||||
|
context.related(suppressedException.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.warn("One or more extensions failed to register (They can be disabled in Plan config).");
|
||||||
|
errorLogger.log(L.WARN, failedToRegisterOne, context.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +138,9 @@ public class ExtensionSvc implements ExtensionService {
|
|||||||
try {
|
try {
|
||||||
pluginsConfig.createSection(pluginName);
|
pluginsConfig.createSection(pluginName);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.WARN, e, ErrorContext.builder()
|
||||||
|
.whatToDo("Create 'Plugins." + pluginName + ".Enabled: true' setting manually.")
|
||||||
|
.related("Section: " + pluginName).build());
|
||||||
logger.warn("Could not register DataExtension for " + pluginName + " due to " + e.toString());
|
logger.warn("Could not register DataExtension for " + pluginName + " due to " + e.toString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -165,21 +175,23 @@ public class ExtensionSvc implements ExtensionService {
|
|||||||
// Try again
|
// Try again
|
||||||
updatePlayerValues(gatherer, playerUUID, playerName, event);
|
updatePlayerValues(gatherer, playerUUID, playerName, event);
|
||||||
} catch (Exception | NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError unexpectedError) {
|
} catch (Exception | NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError unexpectedError) {
|
||||||
logger.warn("Encountered unexpected error with " + gatherer.getPluginName() + " Extension: " + unexpectedError +
|
ErrorContext.Builder context = ErrorContext.builder()
|
||||||
" (but failed safely) when updating value for '" + playerName +
|
.whatToDo("Report and/or disable " + gatherer.getPluginName() + " extension in the Plan config.")
|
||||||
"', stack trace to follow (please report this):");
|
.related(gatherer.getPluginName())
|
||||||
errorLogger.log(L.WARN, gatherer.getClass(), unexpectedError);
|
.related(event)
|
||||||
|
.related("Player: " + playerName + " " + playerUUID);
|
||||||
|
errorLogger.log(L.WARN, unexpectedError, context.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logFailure(String playerName, DataExtensionMethodCallException methodCallFailed) {
|
private void logFailure(String playerName, DataExtensionMethodCallException methodCallFailed) {
|
||||||
Throwable cause = methodCallFailed.getCause();
|
Throwable cause = methodCallFailed.getCause();
|
||||||
String causeName = cause.getClass().getSimpleName();
|
ErrorContext.Builder context = ErrorContext.builder()
|
||||||
logger.warn("Encountered " + causeName + " with " + methodCallFailed.getPluginName() + " Extension" +
|
.whatToDo("Report and/or disable " + methodCallFailed.getPluginName() + " extension in the Plan config.")
|
||||||
" (failed safely) when updating value for '" + playerName +
|
.related(methodCallFailed.getPluginName())
|
||||||
"', the method was disabled temporarily (won't be called until next Plan reload)" +
|
.related("Method:" + methodCallFailed.getMethod().map(MethodWrapper::getMethodName).orElse("-"))
|
||||||
", stack trace to follow (please report this):");
|
.related("Player: " + playerName);
|
||||||
errorLogger.log(L.WARN, getClass(), cause);
|
errorLogger.log(L.WARN, cause, context.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateServerValues(CallEvents event) {
|
public void updateServerValues(CallEvents event) {
|
||||||
@ -206,9 +218,12 @@ public class ExtensionSvc implements ExtensionService {
|
|||||||
// Try again
|
// Try again
|
||||||
updateServerValues(gatherer, event);
|
updateServerValues(gatherer, event);
|
||||||
} catch (Exception | NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError unexpectedError) {
|
} catch (Exception | NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError unexpectedError) {
|
||||||
logger.warn("Encountered unexpected error with " + gatherer.getPluginName() + " Extension: " + unexpectedError +
|
ErrorContext.Builder context = ErrorContext.builder()
|
||||||
" (failed safely) when updating value for server, stack trace to follow (please report this):");
|
.whatToDo("Report and/or disable " + gatherer.getPluginName() + " extension in the Plan config.")
|
||||||
errorLogger.log(L.WARN, gatherer.getClass(), unexpectedError);
|
.related(gatherer.getPluginName())
|
||||||
|
.related(event)
|
||||||
|
.related("Gathering for server");
|
||||||
|
errorLogger.log(L.WARN, unexpectedError, context.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,6 +25,7 @@ import com.djrapitops.plan.settings.locale.lang.PluginLang;
|
|||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
import com.djrapitops.plan.storage.database.Database;
|
import com.djrapitops.plan.storage.database.Database;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.ServerShutdownTransaction;
|
import com.djrapitops.plan.storage.database.transactions.events.ServerShutdownTransaction;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -90,7 +91,11 @@ public abstract class ServerShutdownSave {
|
|||||||
prepareSessionsForStorage(activeSessions, System.currentTimeMillis());
|
prepareSessionsForStorage(activeSessions, System.currentTimeMillis());
|
||||||
return Optional.of(saveActiveSessions(activeSessions));
|
return Optional.of(saveActiveSessions(activeSessions));
|
||||||
} catch (DBInitException e) {
|
} catch (DBInitException e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder()
|
||||||
|
.whatToDo("Find the sessions in the error file and save them manually or ignore. Report & delete the error file after.")
|
||||||
|
.related("Shutdown save failed to init database.")
|
||||||
|
.related(activeSessions)
|
||||||
|
.build());
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
} catch (IllegalStateException ignored) {
|
} catch (IllegalStateException ignored) {
|
||||||
/* Database is not initialized */
|
/* Database is not initialized */
|
||||||
|
@ -99,7 +99,7 @@ public class NicknameCache implements SubSystem {
|
|||||||
NicknameQueries.fetchLastSeenNicknameOfPlayer(uuid, serverInfo.getServerUUID())
|
NicknameQueries.fetchLastSeenNicknameOfPlayer(uuid, serverInfo.getServerUUID())
|
||||||
).map(Nickname::getName);
|
).map(Nickname::getName);
|
||||||
} catch (DBOpException e) {
|
} catch (DBOpException e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e);
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ package com.djrapitops.plan.gathering.timed;
|
|||||||
import com.djrapitops.plan.gathering.SystemUsage;
|
import com.djrapitops.plan.gathering.SystemUsage;
|
||||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||||
import com.djrapitops.plan.settings.config.paths.DataGatheringSettings;
|
import com.djrapitops.plan.settings.config.paths.DataGatheringSettings;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -111,7 +112,8 @@ public class SystemUsageBuffer {
|
|||||||
buffer.freeDiskSpace = SystemUsage.getFreeDiskSpace();
|
buffer.freeDiskSpace = SystemUsage.getFreeDiskSpace();
|
||||||
} catch (SecurityException noPermission) {
|
} catch (SecurityException noPermission) {
|
||||||
if (!diskErrored) {
|
if (!diskErrored) {
|
||||||
errorLogger.log(L.WARN, this.getClass(), noPermission);
|
errorLogger.log(L.WARN, noPermission, ErrorContext.builder()
|
||||||
|
.whatToDo("Resolve " + noPermission.getMessage() + " via OS or JVM permissions").build());
|
||||||
}
|
}
|
||||||
diskErrored = true;
|
diskErrored = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.gathering.timed;
|
package com.djrapitops.plan.gathering.timed;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -45,7 +46,7 @@ public abstract class TPSCounter extends AbsRunnable {
|
|||||||
pulse();
|
pulse();
|
||||||
} catch (Exception | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
|
} catch (Exception | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
|
||||||
logger.error("TPS Count Task Disabled due to error, reload Plan to re-enable.");
|
logger.error("TPS Count Task Disabled due to error, reload Plan to re-enable.");
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().whatToDo("See if a restart fixes this or Report this").build());
|
||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import com.djrapitops.plan.storage.database.DBSystem;
|
|||||||
import com.djrapitops.plan.storage.database.Database;
|
import com.djrapitops.plan.storage.database.Database;
|
||||||
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||||
import com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction;
|
import com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
|
|
||||||
@ -113,8 +114,11 @@ public class ServerServerInfo extends ServerInfo {
|
|||||||
if (!foundServer.isPresent()) {
|
if (!foundServer.isPresent()) {
|
||||||
try {
|
try {
|
||||||
server = registerServer(serverUUID);
|
server = registerServer(serverUUID);
|
||||||
} catch (ExecutionException | IOException e) {
|
} catch (IOException e) {
|
||||||
errorLogger.log(L.CRITICAL, this.getClass(), e);
|
errorLogger.log(L.CRITICAL, e, ErrorContext.builder()
|
||||||
|
.whatToDo("Grant access permissions for writing to " + serverInfoFile.getConfigFilePath()).build());
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
errorLogger.log(L.CRITICAL, e, ErrorContext.builder().build());
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class UUIDUtility {
|
|||||||
try {
|
try {
|
||||||
return dbSystem.getDatabase().query(UserIdentifierQueries.fetchPlayerUUIDOf(playerName));
|
return dbSystem.getDatabase().query(UserIdentifierQueries.fetchPlayerUUIDOf(playerName));
|
||||||
} catch (DBOpException e) {
|
} catch (DBOpException e) {
|
||||||
errorLogger.log(L.ERROR, UUIDUtility.class, e);
|
errorLogger.log(L.ERROR, e);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ package com.djrapitops.plan.processing;
|
|||||||
import com.djrapitops.plan.SubSystem;
|
import com.djrapitops.plan.SubSystem;
|
||||||
import com.djrapitops.plan.settings.locale.Locale;
|
import com.djrapitops.plan.settings.locale.Locale;
|
||||||
import com.djrapitops.plan.settings.locale.lang.PluginLang;
|
import com.djrapitops.plan.settings.locale.lang.PluginLang;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -58,7 +59,7 @@ public class Processing implements SubSystem {
|
|||||||
new BasicThreadFactory.Builder()
|
new BasicThreadFactory.Builder()
|
||||||
.namingPattern(s)
|
.namingPattern(s)
|
||||||
.uncaughtExceptionHandler((thread, throwable) ->
|
.uncaughtExceptionHandler((thread, throwable) ->
|
||||||
errorLogger.log(L.WARN, Processing.class, throwable)
|
errorLogger.log(L.WARN, throwable, ErrorContext.builder().build())
|
||||||
).build());
|
).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,14 +111,14 @@ public class Processing implements SubSystem {
|
|||||||
|
|
||||||
private <T> T exceptionHandlerNonCritical(T t, Throwable throwable) {
|
private <T> T exceptionHandlerNonCritical(T t, Throwable throwable) {
|
||||||
if (throwable != null) {
|
if (throwable != null) {
|
||||||
errorLogger.log(L.WARN, Processing.class, throwable.getCause());
|
errorLogger.log(L.WARN, throwable.getCause(), ErrorContext.builder().build());
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> T exceptionHandlerCritical(T t, Throwable throwable) {
|
private <T> T exceptionHandlerCritical(T t, Throwable throwable) {
|
||||||
if (throwable != null) {
|
if (throwable != null) {
|
||||||
errorLogger.log(L.ERROR, Processing.class, throwable.getCause());
|
errorLogger.log(L.ERROR, throwable.getCause(), ErrorContext.builder().build());
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
@ -163,7 +164,7 @@ public class Processing implements SubSystem {
|
|||||||
try {
|
try {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
} catch (Exception | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
|
} catch (Exception | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
|
||||||
errorLogger.log(L.WARN, this.getClass(), e);
|
errorLogger.log(L.WARN, e, ErrorContext.builder().build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import com.djrapitops.plan.storage.database.Database;
|
|||||||
import com.djrapitops.plan.storage.database.queries.QueryAPIExecutable;
|
import com.djrapitops.plan.storage.database.queries.QueryAPIExecutable;
|
||||||
import com.djrapitops.plan.storage.database.queries.QueryAPIQuery;
|
import com.djrapitops.plan.storage.database.queries.QueryAPIQuery;
|
||||||
import com.djrapitops.plan.storage.database.transactions.Transaction;
|
import com.djrapitops.plan.storage.database.transactions.Transaction;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -107,8 +108,9 @@ public class QuerySvc implements QueryService {
|
|||||||
try {
|
try {
|
||||||
subscriber.accept(playerUUID);
|
subscriber.accept(playerUUID);
|
||||||
} catch (DBOpException e) {
|
} catch (DBOpException e) {
|
||||||
logger.warn("User of Query API (" + subscriber.getClass().getName() + ") ran into exception, failed safely:");
|
errorLogger.log(L.WARN, e, ErrorContext.builder()
|
||||||
errorLogger.log(L.WARN, QueryService.class, e);
|
.whatToDo("Report to this Query API user " + subscriber.getClass().getName())
|
||||||
|
.related("Subscriber: " + subscriber.getClass().getName()).build());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -118,8 +120,9 @@ public class QuerySvc implements QueryService {
|
|||||||
try {
|
try {
|
||||||
function.apply();
|
function.apply();
|
||||||
} catch (DBOpException e) {
|
} catch (DBOpException e) {
|
||||||
logger.warn("User of Query API (" + function.getClass().getName() + ") ran into exception, failed safely:");
|
errorLogger.log(L.WARN, e, ErrorContext.builder()
|
||||||
errorLogger.log(L.WARN, QueryService.class, e);
|
.whatToDo("Report to this Query API user " + function.getClass().getName())
|
||||||
|
.related("Subscriber: " + function.getClass().getName()).build());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import com.djrapitops.plan.settings.config.paths.FormatSettings;
|
|||||||
import com.djrapitops.plan.settings.config.paths.PluginSettings;
|
import com.djrapitops.plan.settings.config.paths.PluginSettings;
|
||||||
import com.djrapitops.plan.settings.theme.Theme;
|
import com.djrapitops.plan.settings.theme.Theme;
|
||||||
import com.djrapitops.plan.storage.file.PlanFiles;
|
import com.djrapitops.plan.storage.file.PlanFiles;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -86,7 +87,7 @@ public abstract class ConfigSystem implements SubSystem {
|
|||||||
|
|
||||||
checkWrongTimeZone();
|
checkWrongTimeZone();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().whatToDo("Fix write permissions to " + config.getConfigFilePath()).build());
|
||||||
throw new EnableException("Failed to save default config: " + e.getMessage(), e);
|
throw new EnableException("Failed to save default config: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
theme.enable();
|
theme.enable();
|
||||||
@ -134,7 +135,7 @@ public abstract class ConfigSystem implements SubSystem {
|
|||||||
try {
|
try {
|
||||||
config.read();
|
config.read();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().whatToDo("Fix read permissions to " + config.getConfigFilePath()).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.settings;
|
|||||||
|
|
||||||
import com.djrapitops.plan.settings.config.ConfigNode;
|
import com.djrapitops.plan.settings.config.ConfigNode;
|
||||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ public class SettingsSvc implements SettingsService {
|
|||||||
try {
|
try {
|
||||||
config.save();
|
config.save();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().whatToDo("Fix write permissions to " + config.getConfigFilePath()).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,4 +98,8 @@ public class Config extends ConfigNode {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(super.hashCode(), configFilePath);
|
return Objects.hash(super.hashCode(), configFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Path getConfigFilePath() {
|
||||||
|
return configFilePath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
|||||||
import com.djrapitops.plan.settings.locale.Locale;
|
import com.djrapitops.plan.settings.locale.Locale;
|
||||||
import com.djrapitops.plan.settings.locale.lang.GenericLang;
|
import com.djrapitops.plan.settings.locale.lang.GenericLang;
|
||||||
import com.djrapitops.plan.settings.locale.lang.HtmlLang;
|
import com.djrapitops.plan.settings.locale.lang.HtmlLang;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
@ -93,7 +94,7 @@ public class WorldAliasSettings {
|
|||||||
try {
|
try {
|
||||||
aliasSect.save();
|
aliasSect.save();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
errorLogger.log(L.WARN, WorldAliasSettings.class, e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().whatToDo("Fix write permissions to " + config.get().getConfigFilePath()).build());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.settings.config.changes;
|
|||||||
|
|
||||||
import com.djrapitops.plan.settings.config.Config;
|
import com.djrapitops.plan.settings.config.Config;
|
||||||
import com.djrapitops.plan.settings.config.paths.FormatSettings;
|
import com.djrapitops.plan.settings.config.paths.FormatSettings;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -152,7 +153,9 @@ public class ConfigUpdater {
|
|||||||
logger.info("Config: " + change.getAppliedMessage());
|
logger.info("Config: " + change.getAppliedMessage());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.WARN, this.getClass(), new IllegalStateException("Failed to apply config update: '" + change.getAppliedMessage() + "'", e));
|
errorLogger.log(L.ERROR, e, ErrorContext.builder()
|
||||||
|
.whatToDo("Fix write permissions to " + config.getConfigFilePath() + " or Report this")
|
||||||
|
.related("Attempt to change: " + change.getAppliedMessage()).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import com.djrapitops.plan.settings.config.PlanConfig;
|
|||||||
import com.djrapitops.plan.settings.config.paths.PluginSettings;
|
import com.djrapitops.plan.settings.config.paths.PluginSettings;
|
||||||
import com.djrapitops.plan.settings.locale.lang.*;
|
import com.djrapitops.plan.settings.locale.lang.*;
|
||||||
import com.djrapitops.plan.storage.file.PlanFiles;
|
import com.djrapitops.plan.storage.file.PlanFiles;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -112,8 +113,7 @@ public class LocaleSystem implements SubSystem {
|
|||||||
}
|
}
|
||||||
new LocaleFileWriter(writing).writeToFile(localeFile);
|
new LocaleFileWriter(writing).writeToFile(localeFile);
|
||||||
} catch (IOException | IllegalStateException e) {
|
} catch (IOException | IllegalStateException e) {
|
||||||
logger.error("Failed to write new Locale file at " + localeFile.getAbsolutePath());
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().whatToDo("Fix write permissions to " + localeFile.getAbsolutePath()).build());
|
||||||
errorLogger.log(L.WARN, this.getClass(), e);
|
|
||||||
}
|
}
|
||||||
resetWriteConfigSetting();
|
resetWriteConfigSetting();
|
||||||
}
|
}
|
||||||
@ -123,8 +123,7 @@ public class LocaleSystem implements SubSystem {
|
|||||||
config.set(PluginSettings.WRITE_NEW_LOCALE, false);
|
config.set(PluginSettings.WRITE_NEW_LOCALE, false);
|
||||||
config.save();
|
config.save();
|
||||||
} catch (IOException | IllegalStateException e) {
|
} catch (IOException | IllegalStateException e) {
|
||||||
logger.error("Failed set WriteNewLocaleFileOnEnable back to false");
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().whatToDo("Fix write permissions to " + config.getConfigFilePath()).build());
|
||||||
errorLogger.log(L.WARN, this.getClass(), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.settings.upkeep;
|
package com.djrapitops.plan.settings.upkeep;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
@ -75,7 +76,7 @@ public class FileWatcher extends Thread {
|
|||||||
watchedPath.register(watcher, ENTRY_MODIFY);
|
watchedPath.register(watcher, ENTRY_MODIFY);
|
||||||
runLoop(watcher);
|
runLoop(watcher);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().build());
|
||||||
interrupt();
|
interrupt();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
interrupt();
|
interrupt();
|
||||||
|
@ -23,6 +23,7 @@ import com.djrapitops.plan.settings.config.PlanConfig;
|
|||||||
import com.djrapitops.plan.settings.config.paths.DatabaseSettings;
|
import com.djrapitops.plan.settings.config.paths.DatabaseSettings;
|
||||||
import com.djrapitops.plan.settings.locale.Locale;
|
import com.djrapitops.plan.settings.locale.Locale;
|
||||||
import com.djrapitops.plan.settings.locale.lang.PluginLang;
|
import com.djrapitops.plan.settings.locale.lang.PluginLang;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -76,7 +77,7 @@ public class MySQLDB extends SQLDB {
|
|||||||
try {
|
try {
|
||||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
errorLogger.log(L.CRITICAL, this.getClass(), e);
|
errorLogger.log(L.CRITICAL, e, ErrorContext.builder().whatToDo("Install MySQL Driver to the server").build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +165,7 @@ public class MySQLDB extends SQLDB {
|
|||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.CRITICAL, e, ErrorContext.builder().related("Closing connection").build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ import com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransa
|
|||||||
import com.djrapitops.plan.storage.database.transactions.init.OperationCriticalTransaction;
|
import com.djrapitops.plan.storage.database.transactions.init.OperationCriticalTransaction;
|
||||||
import com.djrapitops.plan.storage.database.transactions.patches.*;
|
import com.djrapitops.plan.storage.database.transactions.patches.*;
|
||||||
import com.djrapitops.plan.utilities.java.ThrowableUtils;
|
import com.djrapitops.plan.utilities.java.ThrowableUtils;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.api.TimeAmount;
|
import com.djrapitops.plugin.api.TimeAmount;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
@ -92,7 +93,9 @@ public abstract class SQLDB extends AbstractDatabase {
|
|||||||
.namingPattern(nameFormat)
|
.namingPattern(nameFormat)
|
||||||
.uncaughtExceptionHandler((thread, throwable) -> {
|
.uncaughtExceptionHandler((thread, throwable) -> {
|
||||||
if (devMode) {
|
if (devMode) {
|
||||||
errorLogger.log(L.WARN, getClass(), throwable);
|
errorLogger.log(L.WARN, throwable, ErrorContext.builder()
|
||||||
|
.whatToDo("THIS ERROR IS ONLY LOGGED IN DEV MODE")
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
}).build());
|
}).build());
|
||||||
};
|
};
|
||||||
@ -248,10 +251,10 @@ public abstract class SQLDB extends AbstractDatabase {
|
|||||||
}
|
}
|
||||||
transaction.executeTransaction(this);
|
transaction.executeTransaction(this);
|
||||||
return CompletableFuture.completedFuture(null);
|
return CompletableFuture.completedFuture(null);
|
||||||
}, getTransactionExecutor()).handle(errorHandler(origin));
|
}, getTransactionExecutor()).handle(errorHandler(transaction, origin));
|
||||||
}
|
}
|
||||||
|
|
||||||
private BiFunction<CompletableFuture<Object>, Throwable, CompletableFuture<Object>> errorHandler(Exception origin) {
|
private BiFunction<CompletableFuture<Object>, Throwable, CompletableFuture<Object>> errorHandler(Transaction transaction, Exception origin) {
|
||||||
return (obj, throwable) -> {
|
return (obj, throwable) -> {
|
||||||
if (throwable == null) {
|
if (throwable == null) {
|
||||||
return CompletableFuture.completedFuture(null);
|
return CompletableFuture.completedFuture(null);
|
||||||
@ -261,7 +264,8 @@ public abstract class SQLDB extends AbstractDatabase {
|
|||||||
}
|
}
|
||||||
ThrowableUtils.appendEntryPointToCause(throwable, origin);
|
ThrowableUtils.appendEntryPointToCause(throwable, origin);
|
||||||
|
|
||||||
errorLogger.log(L.ERROR, getClass(), throwable);
|
errorLogger.log(L.ERROR, throwable, ErrorContext.builder()
|
||||||
|
.related("Transaction: " + transaction.getClass()).build());
|
||||||
return CompletableFuture.completedFuture(null);
|
return CompletableFuture.completedFuture(null);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import com.djrapitops.plan.storage.file.PlanFiles;
|
|||||||
import com.djrapitops.plan.storage.upkeep.DBKeepAliveTask;
|
import com.djrapitops.plan.storage.upkeep.DBKeepAliveTask;
|
||||||
import com.djrapitops.plan.utilities.MiscUtils;
|
import com.djrapitops.plan.utilities.MiscUtils;
|
||||||
import com.djrapitops.plan.utilities.java.ThrowableUtils;
|
import com.djrapitops.plan.utilities.java.ThrowableUtils;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -80,8 +81,8 @@ public class SQLiteDB extends SQLDB {
|
|||||||
try {
|
try {
|
||||||
Class.forName("org.sqlite.JDBC");
|
Class.forName("org.sqlite.JDBC");
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
errorLogger.log(L.CRITICAL, this.getClass(), e);
|
errorLogger.log(L.CRITICAL, e, ErrorContext.builder().whatToDo("Install SQLite Driver to the server").build());
|
||||||
return null; // Should never happen.
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String dbFilePath = dbFile.getAbsolutePath();
|
String dbFilePath = dbFile.getAbsolutePath();
|
||||||
|
@ -115,7 +115,7 @@ public class DBCleanTask extends AbsRunnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (DBOpException e) {
|
} catch (DBOpException e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e);
|
||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package com.djrapitops.plan.storage.upkeep;
|
package com.djrapitops.plan.storage.upkeep;
|
||||||
|
|
||||||
import com.djrapitops.plan.utilities.MiscUtils;
|
import com.djrapitops.plan.utilities.MiscUtils;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -59,7 +60,8 @@ public class DBKeepAliveTask extends AbsRunnable {
|
|||||||
try {
|
try {
|
||||||
connection = iReconnect.reconnect();
|
connection = iReconnect.reconnect();
|
||||||
} catch (SQLException reconnectionError) {
|
} catch (SQLException reconnectionError) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), reconnectionError);
|
errorLogger.log(L.ERROR, reconnectionError, ErrorContext.builder()
|
||||||
|
.whatToDo("Reload Plan and Report this if the issue persists").build());
|
||||||
logger.error("SQL connection maintaining task had to be closed due to exception.");
|
logger.error("SQL connection maintaining task had to be closed due to exception.");
|
||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
|
@ -42,12 +42,17 @@ public class ErrorContext {
|
|||||||
|
|
||||||
public Collection<String> toLines() {
|
public Collection<String> toLines() {
|
||||||
List<String> lines = new ArrayList<>();
|
List<String> lines = new ArrayList<>();
|
||||||
|
getWhatToDo().ifPresent(lines::add);
|
||||||
for (Object o : related) {
|
for (Object o : related) {
|
||||||
lines.add(Objects.toString(o));
|
lines.add(Objects.toString(o));
|
||||||
}
|
}
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void merge(ErrorContext context) {
|
||||||
|
this.related.addAll(context.related);
|
||||||
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private final ErrorContext context;
|
private final ErrorContext context;
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.utilities.logging;
|
|||||||
|
|
||||||
import com.djrapitops.plan.PlanPlugin;
|
import com.djrapitops.plan.PlanPlugin;
|
||||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||||
|
import com.djrapitops.plan.exceptions.ExceptionWithContext;
|
||||||
import com.djrapitops.plan.identification.properties.ServerProperties;
|
import com.djrapitops.plan.identification.properties.ServerProperties;
|
||||||
import com.djrapitops.plan.storage.file.PlanFiles;
|
import com.djrapitops.plan.storage.file.PlanFiles;
|
||||||
import com.djrapitops.plan.utilities.java.Lists;
|
import com.djrapitops.plan.utilities.java.Lists;
|
||||||
@ -76,11 +77,16 @@ public class ErrorLogger implements ErrorHandler {
|
|||||||
this.formatters = formatters;
|
this.formatters = formatters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T extends ExceptionWithContext> void log(L level, T throwable) {
|
||||||
|
log(level, (Throwable) throwable, throwable.getContext().orElse(ErrorContext.builder().related("Missing Context").build()));
|
||||||
|
}
|
||||||
|
|
||||||
public void log(L level, Throwable throwable, ErrorContext context) {
|
public void log(L level, Throwable throwable, ErrorContext context) {
|
||||||
String errorName = throwable.getClass().getSimpleName();
|
String errorName = throwable.getClass().getSimpleName();
|
||||||
String hash = hash(throwable);
|
String hash = hash(throwable);
|
||||||
Path logsDir = files.getLogsDirectory();
|
Path logsDir = files.getLogsDirectory();
|
||||||
Path errorLog = logsDir.resolve(errorName + "-" + hash + ".txt");
|
Path errorLog = logsDir.resolve(errorName + "-" + hash + ".txt");
|
||||||
|
mergeAdditionalContext(throwable, context);
|
||||||
if (Files.exists(errorLog)) {
|
if (Files.exists(errorLog)) {
|
||||||
logExisting(errorLog, throwable, context);
|
logExisting(errorLog, throwable, context);
|
||||||
} else {
|
} else {
|
||||||
@ -93,6 +99,16 @@ public class ErrorLogger implements ErrorHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void mergeAdditionalContext(Throwable throwable, ErrorContext context) {
|
||||||
|
Throwable cause = throwable.getCause();
|
||||||
|
while (cause != null) {
|
||||||
|
if (cause instanceof ExceptionWithContext) {
|
||||||
|
((ExceptionWithContext) cause).getContext().ifPresent(context::merge);
|
||||||
|
}
|
||||||
|
cause = cause.getCause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void logExisting(Path errorLog, Throwable throwable, ErrorContext context) {
|
private void logExisting(Path errorLog, Throwable throwable, ErrorContext context) {
|
||||||
// Read existing
|
// Read existing
|
||||||
List<String> lines;
|
List<String> lines;
|
||||||
@ -232,6 +248,13 @@ public class ErrorLogger implements ErrorHandler {
|
|||||||
for (StackTraceElement element : e.getStackTrace()) {
|
for (StackTraceElement element : e.getStackTrace()) {
|
||||||
trace.add(" " + element);
|
trace.add(" " + element);
|
||||||
}
|
}
|
||||||
|
Throwable[] suppressed = e.getSuppressed();
|
||||||
|
if (suppressed.length > 0) {
|
||||||
|
for (Throwable suppressedThrowable : suppressed) {
|
||||||
|
trace.add(" Suppressed:");
|
||||||
|
buildReadableStacktrace(suppressedThrowable).stream().map(line -> " " + line).forEach(trace::add);
|
||||||
|
}
|
||||||
|
}
|
||||||
Throwable cause = e.getCause();
|
Throwable cause = e.getCause();
|
||||||
if (cause != null) {
|
if (cause != null) {
|
||||||
trace.add("Caused by:");
|
trace.add("Caused by:");
|
||||||
|
@ -24,12 +24,12 @@ import com.djrapitops.plan.delivery.domain.keys.PlayerKeys;
|
|||||||
import com.djrapitops.plan.gathering.cache.SessionCache;
|
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||||
import com.djrapitops.plan.placeholder.PlanPlaceholders;
|
import com.djrapitops.plan.placeholder.PlanPlaceholders;
|
||||||
import com.djrapitops.plan.storage.database.queries.containers.ContainerFetchQueries;
|
import com.djrapitops.plan.storage.database.queries.containers.ContainerFetchQueries;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,9 +60,9 @@ public class NukkitPlaceholderRegistrar {
|
|||||||
placeholders.getPlaceholders().forEach((name, loader) ->
|
placeholders.getPlaceholders().forEach((name, loader) ->
|
||||||
api.visitorSensitivePlaceholder(name, (player, params) -> {
|
api.visitorSensitivePlaceholder(name, (player, params) -> {
|
||||||
try {
|
try {
|
||||||
return loader.apply(getPlayer(player), new ArrayList<>(params.getAll().values()));
|
return loader.apply(getPlayer(player), params.get());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.WARN, getClass(), e);
|
errorLogger.log(L.WARN, e, ErrorContext.builder().related("Registering PlaceholderAPI").build());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,9 +71,9 @@ public class NukkitPlaceholderRegistrar {
|
|||||||
placeholders.getStaticPlaceholders().forEach((name, loader) ->
|
placeholders.getStaticPlaceholders().forEach((name, loader) ->
|
||||||
api.staticPlaceholder(name, params -> {
|
api.staticPlaceholder(name, params -> {
|
||||||
try {
|
try {
|
||||||
return loader.apply(new ArrayList<>(params.getAll().values()));
|
return loader.apply(params.get());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.WARN, getClass(), e);
|
errorLogger.log(L.WARN, e, ErrorContext.builder().related("Registering PlaceholderAPI").build());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import com.djrapitops.plan.gathering.cache.NicknameCache;
|
|||||||
import com.djrapitops.plan.identification.ServerInfo;
|
import com.djrapitops.plan.identification.ServerInfo;
|
||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction;
|
import com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ public class ChatListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
actOnChatEvent(event);
|
actOnChatEvent(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ import com.djrapitops.plan.gathering.domain.Session;
|
|||||||
import com.djrapitops.plan.processing.Processing;
|
import com.djrapitops.plan.processing.Processing;
|
||||||
import com.djrapitops.plan.processing.processors.player.MobKillProcessor;
|
import com.djrapitops.plan.processing.processors.player.MobKillProcessor;
|
||||||
import com.djrapitops.plan.processing.processors.player.PlayerKillProcessor;
|
import com.djrapitops.plan.processing.processors.player.PlayerKillProcessor;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ public class DeathEventListener implements Listener {
|
|||||||
UUID uuid = dead.getUniqueId();
|
UUID uuid = dead.getUniqueId();
|
||||||
handleKill(time, uuid, killerEntity);
|
handleKill(time, uuid, killerEntity);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event, dead).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +99,7 @@ public class DeathEventListener implements Listener {
|
|||||||
|
|
||||||
handleKill(time, /* Not a player */ null, killerEntity);
|
handleKill(time, /* Not a player */ null, killerEntity);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event, dead).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import com.djrapitops.plan.identification.ServerInfo;
|
|||||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ public class GameModeChangeListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
actOnEvent(event);
|
actOnEvent(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event, event.getPlayer().getGamemode() + "->" + event.getNewGamemode()).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import cn.nukkit.event.player.*;
|
|||||||
import com.djrapitops.plan.gathering.afk.AFKTracker;
|
import com.djrapitops.plan.gathering.afk.AFKTracker;
|
||||||
import com.djrapitops.plan.settings.Permissions;
|
import com.djrapitops.plan.settings.Permissions;
|
||||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ public class NukkitAFKListener implements Listener {
|
|||||||
|
|
||||||
AFK_TRACKER.performedAction(uuid, time);
|
AFK_TRACKER.performedAction(uuid, time);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ import com.djrapitops.plan.settings.config.paths.ExportSettings;
|
|||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
import com.djrapitops.plan.storage.database.Database;
|
import com.djrapitops.plan.storage.database.Database;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.*;
|
import com.djrapitops.plan.storage.database.transactions.events.*;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
|
|
||||||
@ -105,7 +106,7 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
boolean operator = event.getPlayer().isOp();
|
boolean operator = event.getPlayer().isOp();
|
||||||
dbSystem.getDatabase().executeTransaction(new OperatorStatusTransaction(playerUUID, operator));
|
dbSystem.getDatabase().executeTransaction(new OperatorStatusTransaction(playerUUID, operator));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +131,7 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
|
|
||||||
dbSystem.getDatabase().executeTransaction(new KickStoreTransaction(uuid));
|
dbSystem.getDatabase().executeTransaction(new KickStoreTransaction(uuid));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +140,7 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
actOnJoinEvent(event);
|
actOnJoinEvent(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +205,7 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
actOnQuitEvent(event);
|
actOnQuitEvent(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import com.djrapitops.plan.identification.ServerInfo;
|
|||||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
|
|
||||||
@ -61,7 +62,7 @@ public class WorldChangeListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
actOnEvent(event);
|
actOnEvent(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ import com.djrapitops.plan.settings.config.paths.ExportSettings;
|
|||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
import com.djrapitops.plan.storage.database.Database;
|
import com.djrapitops.plan.storage.database.Database;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.*;
|
import com.djrapitops.plan.storage.database.transactions.events.*;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import org.spongepowered.api.Sponge;
|
import org.spongepowered.api.Sponge;
|
||||||
@ -105,7 +106,7 @@ public class PlayerOnlineListener {
|
|||||||
try {
|
try {
|
||||||
actOnLoginEvent(event);
|
actOnLoginEvent(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ public class PlayerOnlineListener {
|
|||||||
}
|
}
|
||||||
dbSystem.getDatabase().executeTransaction(new KickStoreTransaction(playerUUID));
|
dbSystem.getDatabase().executeTransaction(new KickStoreTransaction(playerUUID));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +144,7 @@ public class PlayerOnlineListener {
|
|||||||
try {
|
try {
|
||||||
actOnJoinEvent(event);
|
actOnJoinEvent(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +209,7 @@ public class PlayerOnlineListener {
|
|||||||
try {
|
try {
|
||||||
actOnQuitEvent(event);
|
actOnQuitEvent(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ package com.djrapitops.plan.gathering.listeners.sponge;
|
|||||||
import com.djrapitops.plan.gathering.afk.AFKTracker;
|
import com.djrapitops.plan.gathering.afk.AFKTracker;
|
||||||
import com.djrapitops.plan.settings.Permissions;
|
import com.djrapitops.plan.settings.Permissions;
|
||||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import org.spongepowered.api.entity.living.player.Player;
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
@ -71,7 +72,7 @@ public class SpongeAFKListener {
|
|||||||
try {
|
try {
|
||||||
performedAction(event.getTargetEntity());
|
performedAction(event.getTargetEntity());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import com.djrapitops.plan.gathering.cache.NicknameCache;
|
|||||||
import com.djrapitops.plan.identification.ServerInfo;
|
import com.djrapitops.plan.identification.ServerInfo;
|
||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction;
|
import com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import org.spongepowered.api.entity.living.player.Player;
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
@ -66,7 +67,7 @@ public class SpongeChatListener {
|
|||||||
try {
|
try {
|
||||||
actOnChatEvent(player);
|
actOnChatEvent(player);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import com.djrapitops.plan.gathering.domain.Session;
|
|||||||
import com.djrapitops.plan.processing.Processing;
|
import com.djrapitops.plan.processing.Processing;
|
||||||
import com.djrapitops.plan.processing.processors.player.MobKillProcessor;
|
import com.djrapitops.plan.processing.processors.player.MobKillProcessor;
|
||||||
import com.djrapitops.plan.processing.processors.player.PlayerKillProcessor;
|
import com.djrapitops.plan.processing.processors.player.PlayerKillProcessor;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import org.spongepowered.api.data.key.Keys;
|
import org.spongepowered.api.data.key.Keys;
|
||||||
@ -81,7 +82,7 @@ public class SpongeDeathListener {
|
|||||||
handleKill(time, dead, killerEntity);
|
handleKill(time, dead, killerEntity);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event, dead).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import com.djrapitops.plan.identification.ServerInfo;
|
|||||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import org.spongepowered.api.entity.living.player.Player;
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
@ -67,7 +68,7 @@ public class SpongeGMChangeListener {
|
|||||||
try {
|
try {
|
||||||
actOnGMChangeEvent(event);
|
actOnGMChangeEvent(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event, event.getGameMode()).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import com.djrapitops.plan.identification.ServerInfo;
|
|||||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import org.spongepowered.api.data.key.Keys;
|
import org.spongepowered.api.data.key.Keys;
|
||||||
@ -70,7 +71,7 @@ public class SpongeWorldChangeListener {
|
|||||||
try {
|
try {
|
||||||
actOnEvent(event, player);
|
actOnEvent(event, player);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ import com.djrapitops.plan.storage.database.DBSystem;
|
|||||||
import com.djrapitops.plan.storage.database.Database;
|
import com.djrapitops.plan.storage.database.Database;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.GeoInfoStoreTransaction;
|
import com.djrapitops.plan.storage.database.transactions.events.GeoInfoStoreTransaction;
|
||||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
|
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
|
||||||
|
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.velocitypowered.api.event.PostOrder;
|
import com.velocitypowered.api.event.PostOrder;
|
||||||
@ -96,7 +97,7 @@ public class PlayerOnlineListener {
|
|||||||
try {
|
try {
|
||||||
actOnLogin(event);
|
actOnLogin(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.WARN, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +148,7 @@ public class PlayerOnlineListener {
|
|||||||
try {
|
try {
|
||||||
actOnLogout(event);
|
actOnLogout(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.WARN, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +186,7 @@ public class PlayerOnlineListener {
|
|||||||
try {
|
try {
|
||||||
actOnServerSwitch(event);
|
actOnServerSwitch(event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.WARN, this.getClass(), e);
|
errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user