removed most of the usages of e.printStrackTrace() and e.getMessage() ...
... by using appropriate logging methodsmaster
parent
05206b3fea
commit
5fcfe5cb43
|
@ -170,8 +170,7 @@ public class Amidst {
|
|||
try {
|
||||
new Application(parameters, metadata, settings).run();
|
||||
} catch (DotMinecraftDirectoryNotFoundException e) {
|
||||
AmidstLogger.warn(e.getMessage());
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e);
|
||||
AmidstMessageBox.displayError(
|
||||
"Please install Minecraft",
|
||||
"Amidst is not able to find your '.minecraft' directory, but it requires a working Minecraft installation.");
|
||||
|
|
|
@ -20,8 +20,7 @@ public class License {
|
|||
try {
|
||||
return ResourceLoader.getResourceAsString(path);
|
||||
} catch (IOException e) {
|
||||
AmidstLogger.warn("Unable to read license for '" + name + "' at '" + path + "'.");
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e, "Unable to read license for '" + name + "' at '" + path + "'.");
|
||||
return "License text is missing.";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -331,7 +331,7 @@ public class Actions {
|
|||
try {
|
||||
ImageIO.write(image, "png", file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e);
|
||||
mainWindow.displayException(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import amidst.gui.main.viewer.ViewerFacade;
|
|||
import amidst.gui.main.viewer.ViewerFacadeBuilder;
|
||||
import amidst.gui.seedsearcher.SeedSearcher;
|
||||
import amidst.gui.seedsearcher.SeedSearcherWindow;
|
||||
import amidst.logging.AmidstLogger;
|
||||
import amidst.logging.AmidstMessageBox;
|
||||
import amidst.mojangapi.MojangApi;
|
||||
import amidst.mojangapi.file.MojangApiParsingException;
|
||||
|
@ -148,7 +149,7 @@ public class MainWindow {
|
|||
try {
|
||||
setWorld(mojangApi.createWorldFromSeed(worldSeed, worldType));
|
||||
} catch (IllegalStateException | MinecraftInterfaceException e) {
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e);
|
||||
displayException(e);
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +159,7 @@ public class MainWindow {
|
|||
try {
|
||||
setWorld(mojangApi.createWorldFromSaveGame(file));
|
||||
} catch (IllegalStateException | MinecraftInterfaceException | IOException | MojangApiParsingException e) {
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e);
|
||||
displayException(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ public class UpdatePrompt {
|
|||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
private void displayError(Exception e) {
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e);
|
||||
exceptionConsumer.accept(e);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,10 +75,8 @@ public class CursorInformationWidget extends TextWidget {
|
|||
try {
|
||||
return Biome.getByIndex(biome).getName();
|
||||
} catch (UnknownBiomeIndexException e) {
|
||||
String message = e.getMessage();
|
||||
AmidstLogger.error(message);
|
||||
AmidstMessageBox.displayError("Error", message);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.error(e);
|
||||
AmidstMessageBox.displayError("Error", e);
|
||||
return UNKNOWN_BIOME_NAME;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -59,7 +59,7 @@ public class LocalProfileComponent extends ProfileComponent {
|
|||
versionDirectory = profile.createValidVersionDirectory(mojangApi);
|
||||
return true;
|
||||
} catch (FileNotFoundException e) {
|
||||
AmidstLogger.warn(e.getMessage());
|
||||
AmidstLogger.warn(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -89,18 +89,19 @@ public class LocalProfileComponent extends ProfileComponent {
|
|||
|
||||
String possibleModProfiles = ".*(optifine|forge).*";
|
||||
if (Pattern.matches(possibleModProfiles, getVersionName().toLowerCase(Locale.ENGLISH))) {
|
||||
AmidstLogger.error("Amidst does not support modded Minecraft profiles! Please select or create an unmodded Minecraft profile via the Minecraft Launcher.");
|
||||
AmidstMessageBox.displayError("Error", "Amidst does not support modded Minecraft profiles! Please select or create an unmodded Minecraft profile via the Minecraft Launcher.");
|
||||
AmidstLogger.error(
|
||||
"Amidst does not support modded Minecraft profiles! Please select or create an unmodded Minecraft profile via the Minecraft Launcher.");
|
||||
AmidstMessageBox.displayError(
|
||||
"Error",
|
||||
"Amidst does not support modded Minecraft profiles! Please select or create an unmodded Minecraft profile via the Minecraft Launcher.");
|
||||
return false;
|
||||
}
|
||||
|
||||
mojangApi.set(getProfileName(), profileDirectory, versionDirectory);
|
||||
return true;
|
||||
} catch (LocalMinecraftInterfaceCreationException e) {
|
||||
String message = e.getMessage();
|
||||
AmidstLogger.error(message);
|
||||
AmidstMessageBox.displayError("Error", message);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.error(e);
|
||||
AmidstMessageBox.displayError("Error", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,9 +155,8 @@ public class ProfileSelectWindow {
|
|||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
private void scanAndLoadProfilesFailed(Exception e) {
|
||||
AmidstLogger.error("Error reading launcher_profiles.json");
|
||||
AmidstMessageBox.displayError("Error", "Error reading launcher_profiles.json");
|
||||
e.printStackTrace();
|
||||
AmidstLogger.error(e, "Error reading launcher_profiles.json");
|
||||
AmidstMessageBox.displayError("Error", e, "Error reading launcher_profiles.json");
|
||||
profileSelectPanel.setEmptyMessage("Failed loading");
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import amidst.documentation.AmidstThread;
|
|||
import amidst.documentation.CalledOnlyBy;
|
||||
import amidst.documentation.NotThreadSafe;
|
||||
import amidst.gui.main.MainWindow;
|
||||
import amidst.logging.AmidstLogger;
|
||||
import amidst.mojangapi.MojangApi;
|
||||
import amidst.mojangapi.minecraftinterface.MinecraftInterfaceException;
|
||||
import amidst.mojangapi.world.World;
|
||||
|
@ -67,7 +68,7 @@ public class SeedSearcher {
|
|||
try {
|
||||
doSearch(reporter, configuration);
|
||||
} catch (IllegalStateException | MinecraftInterfaceException e) {
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e);
|
||||
mainWindow.displayException(e);
|
||||
} finally {
|
||||
this.isSearching = false;
|
||||
|
|
|
@ -71,8 +71,7 @@ public class FileLogger implements Logger {
|
|||
|
||||
@CalledOnlyBy(AmidstThread.STARTUP)
|
||||
private void disableBecauseFileCreationThrowsException(IOException e) {
|
||||
AmidstLogger.warn("Unable to create new file at: " + file + " disabling logging to file.");
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e, "Unable to create new file at: " + file + " disabling logging to file.");
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.STARTUP)
|
||||
|
@ -117,8 +116,7 @@ public class FileLogger implements Logger {
|
|||
try (FileWriter writer = new FileWriter(file, true)) {
|
||||
writer.append(logMessage);
|
||||
} catch (IOException e) {
|
||||
AmidstLogger.warn("Unable to write to log file.");
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e, "Unable to write to log file.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,7 @@ public enum LibraryFinder {
|
|||
result.add(libraryFile.toURI().toURL());
|
||||
AmidstLogger.info("Found library: " + libraryFile);
|
||||
} catch (MalformedURLException e) {
|
||||
AmidstLogger.warn("Unable to convert library file to URL: " + libraryFile);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e, "Unable to convert library file to URL: " + libraryFile);
|
||||
}
|
||||
} else {
|
||||
AmidstLogger.info("Skipping library: " + library.getName());
|
||||
|
|
|
@ -78,8 +78,7 @@ public class VersionListEntryJson {
|
|||
downloadServer(prefix);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
AmidstLogger.warn("unable to download server: " + id);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e, "unable to download server: " + id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -89,8 +88,7 @@ public class VersionListEntryJson {
|
|||
downloadClient(prefix);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
AmidstLogger.warn("unable to download client: " + id);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e, "unable to download client: " + id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -82,8 +82,7 @@ public class SeedHistoryLogger {
|
|||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
AmidstLogger.warn("Unable to create seed history file: " + file);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e, "Unable to create seed history file: " + file);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,8 +90,7 @@ public class SeedHistoryLogger {
|
|||
try (PrintStream stream = new PrintStream(new FileOutputStream(file, true))) {
|
||||
stream.println(line);
|
||||
} catch (IOException e) {
|
||||
AmidstLogger.warn("Unable to write to seed history file: " + file);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e, "Unable to write to seed history file: " + file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,16 +35,12 @@ public class TempleWorldIconTypeProvider implements WorldIconTypeProvider<Void>
|
|||
return null;
|
||||
}
|
||||
} catch (UnknownBiomeIndexException e) {
|
||||
String message = e.getMessage();
|
||||
AmidstLogger.error(message);
|
||||
AmidstMessageBox.displayError("Error", message);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.error(e);
|
||||
AmidstMessageBox.displayError("Error", e);
|
||||
return null;
|
||||
} catch (MinecraftInterfaceException e) {
|
||||
String message = e.getMessage();
|
||||
AmidstLogger.error(message);
|
||||
AmidstMessageBox.displayError("Error", message);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.error(e);
|
||||
AmidstMessageBox.displayError("Error", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,10 +31,8 @@ public class BiomeDataOracle {
|
|||
try {
|
||||
copyToResult(result, width, height, getBiomeData(left, top, width, height, useQuarterResolution));
|
||||
} catch (MinecraftInterfaceException e) {
|
||||
String message = e.getMessage();
|
||||
AmidstLogger.error(message);
|
||||
AmidstMessageBox.displayError("Error", message);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.error(e);
|
||||
AmidstMessageBox.displayError("Error", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,16 +57,12 @@ public class BiomeDataOracle {
|
|||
try {
|
||||
return validBiomes.contains(getBiomeAt(x, y));
|
||||
} catch (UnknownBiomeIndexException e) {
|
||||
String message = e.getMessage();
|
||||
AmidstLogger.error(message);
|
||||
AmidstMessageBox.displayError("Error", message);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.error(e);
|
||||
AmidstMessageBox.displayError("Error", e);
|
||||
return false;
|
||||
} catch (MinecraftInterfaceException e) {
|
||||
String message = e.getMessage();
|
||||
AmidstLogger.error(message);
|
||||
AmidstMessageBox.displayError("Error", message);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.error(e);
|
||||
AmidstMessageBox.displayError("Error", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -93,16 +87,12 @@ public class BiomeDataOracle {
|
|||
}
|
||||
return true;
|
||||
} catch (UnknownBiomeIndexException e) {
|
||||
String message = e.getMessage();
|
||||
AmidstLogger.error(message);
|
||||
AmidstMessageBox.displayError("Error", message);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.error(e);
|
||||
AmidstMessageBox.displayError("Error", e);
|
||||
return false;
|
||||
} catch (MinecraftInterfaceException e) {
|
||||
String message = e.getMessage();
|
||||
AmidstLogger.error(message);
|
||||
AmidstMessageBox.displayError("Error", message);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.error(e);
|
||||
AmidstMessageBox.displayError("Error", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -137,16 +127,12 @@ public class BiomeDataOracle {
|
|||
}
|
||||
return result;
|
||||
} catch (UnknownBiomeIndexException e) {
|
||||
String message = e.getMessage();
|
||||
AmidstLogger.error(message);
|
||||
AmidstMessageBox.displayError("Error", message);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.error(e);
|
||||
AmidstMessageBox.displayError("Error", e);
|
||||
return null;
|
||||
} catch (MinecraftInterfaceException e) {
|
||||
String message = e.getMessage();
|
||||
AmidstLogger.error(message);
|
||||
AmidstMessageBox.displayError("Error", message);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.error(e);
|
||||
AmidstMessageBox.displayError("Error", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,8 +49,7 @@ public class Player {
|
|||
return false;
|
||||
}
|
||||
} catch (MojangApiParsingException e) {
|
||||
AmidstLogger.warn("error while writing player location for player: " + getPlayerName());
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e, "error while writing player location for player: " + getPlayerName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -78,8 +77,7 @@ public class Player {
|
|||
loadLocation();
|
||||
return true;
|
||||
} catch (IOException | MojangApiParsingException e) {
|
||||
AmidstLogger.warn("error while reading player location for player: " + getPlayerName());
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e, "error while reading player location for player: " + getPlayerName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,8 +101,7 @@ public class BiomeProfileDirectory {
|
|||
}
|
||||
profile.validate();
|
||||
} catch (JsonSyntaxException | JsonIOException | IOException | NullPointerException e) {
|
||||
AmidstLogger.warn("Unable to load file: " + file);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.warn(e, "Unable to load file: " + file);
|
||||
}
|
||||
}
|
||||
return profile;
|
||||
|
|
|
@ -18,10 +18,8 @@ public class BiomeProfileSelection {
|
|||
try {
|
||||
return getBiomeColor(index);
|
||||
} catch (UnknownBiomeIndexException e) {
|
||||
String message = e.getMessage();
|
||||
AmidstLogger.error(message);
|
||||
AmidstMessageBox.displayError("Error", message);
|
||||
e.printStackTrace();
|
||||
AmidstLogger.error(e);
|
||||
AmidstMessageBox.displayError("Error", e);
|
||||
return BiomeColor.unknown();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue