cleanup MySQL throws

This commit is contained in:
DNx5 2015-09-16 11:36:08 +07:00
parent 6a8e581ba8
commit 51067498ea

View File

@ -64,58 +64,29 @@ public class MySQL implements DataSource {
// Set the connection arguments (and check if connection is ok)
try {
this.setConnectionArguments();
} catch (ClassNotFoundException ne) {
ConsoleLogger.showError(ne.getMessage());
ConsoleLogger.showError("Can't use the Hikari Connection Pool! Please, report this error to the developer! SHUTDOWN...");
this.close();
if (Settings.isStopEnabled) {
AuthMe.getInstance().getServer().shutdown();
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
} else {
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
}
throw new ClassNotFoundException(ne.getMessage());
} catch (IllegalArgumentException ae) { // This means that there are problems with the hikaricp pool arguments!
ConsoleLogger.showError(ae.getMessage());
} catch (RuntimeException e) {
if (e instanceof IllegalArgumentException) {
ConsoleLogger.showError("Invalid database arguments! Please check your configuration!");
ConsoleLogger.showError("If this error persists, please report it to the developer! SHUTDOWN...");
this.close();
if (Settings.isStopEnabled) {
AuthMe.getInstance().getServer().shutdown();
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
} else {
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
throw new IllegalArgumentException(e);
}
throw new IllegalArgumentException(ae);
} catch (PoolInitializationException ie) { // Can't initialize the connection pool!
ConsoleLogger.showError(ie.getMessage());
ConsoleLogger.showError("Can't connect to the MySql database! Please check your configuration!");
if (e instanceof PoolInitializationException) {
ConsoleLogger.showError("Can't initialize database connection! Please check your configuration!");
ConsoleLogger.showError("If this error persists, please report it to the developer! SHUTDOWN...");
this.close();
if (Settings.isStopEnabled) {
AuthMe.getInstance().getServer().shutdown();
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
} else {
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
throw new PoolInitializationException(e);
}
throw new PoolInitializationException(ie);
ConsoleLogger.showError("Can't use the Hikari Connection Pool! Please, report this error to the developer! SHUTDOWN...");
throw e;
}
// Initialize the database
try {
this.setupConnection();
} catch (SQLException e) {
ConsoleLogger.showError(e.getMessage());
this.close();
ConsoleLogger.showError("Can't initialize the MySQL database... Please check your database settings in the config.yml file! SHUTDOWN...");
ConsoleLogger.showError("If this error persists, please report it to the developer! SHUTDOWN...");
this.close();
if (Settings.isStopEnabled) {
AuthMe.getInstance().getServer().shutdown();
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
} else {
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
}
throw new SQLException(e);
throw e;
}
}