Replace printStackTrace with Logger.throwing in various classes
The changes made in these classes are intended to improve error handling and visibility. Instead of simply printing the StackTrace, the Logger.throwing method is now used to send error messages to the logger in a more controlled manner. This should facilitate better error tracking and resolution. The affected classes include database, configuration, and quest implementation classes.
This commit is contained in:
@@ -32,7 +32,7 @@ public class Database {
|
||||
try {
|
||||
openConnection();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
Logger.throwing(Database.class.getName(), "init", e);
|
||||
}
|
||||
|
||||
//Run all create table functions
|
||||
@@ -45,8 +45,7 @@ public class Database {
|
||||
} catch (InvocationTargetException ex) {
|
||||
throw new RuntimeException(ex.getCause());
|
||||
} catch (Exception ex) {
|
||||
Logger.severe("Error invoking %.", method.toString());
|
||||
ex.printStackTrace();
|
||||
Logger.throwing(Database.class.getName(), "init", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,7 +68,7 @@ public class Database {
|
||||
try {
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
Logger.throwing(Database.class.getName(), "openConnection", e);
|
||||
}
|
||||
|
||||
connection = DriverManager.getConnection(
|
||||
@@ -83,7 +82,7 @@ public class Database {
|
||||
try {
|
||||
openConnection();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
Logger.throwing(Database.class.getName(), "getConnection", e);
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
@@ -103,7 +102,7 @@ public class Database {
|
||||
")";
|
||||
getDatabase().getConnection().prepareStatement(sql).executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
Logger.throwing(Database.class.getName(), "createUserPointsTable", e);
|
||||
Logger.severe("Error while trying to create user point table");
|
||||
Logger.severe("Shutting down AltitudeQuests");
|
||||
Bukkit.getPluginManager().disablePlugin(AQuest.getInstance());
|
||||
@@ -121,9 +120,8 @@ public class Database {
|
||||
")";
|
||||
getDatabase().getConnection().prepareStatement(sql).executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
Logger.severe("Error while trying to create quest log table");
|
||||
Logger.severe("Shutting down AltitudeQuests");
|
||||
Logger.throwing(Database.class.getName(), "createQuestLogTable", e);
|
||||
Logger.severe("Error while trying to create quest log table\nShutting down AltitudeQuests");
|
||||
Bukkit.getPluginManager().disablePlugin(AQuest.getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user