ensured that all displayed errors are also logged

master
Stefan Dollase 2016-11-21 04:00:55 +01:00
parent 5fcfe5cb43
commit b446cdd729
4 changed files with 19 additions and 18 deletions

View File

@ -148,6 +148,7 @@ public class Actions {
viewerFacade.centerOn(player);
}
} else {
AmidstLogger.warn("There are no players in this world.");
mainWindow.displayError("There are no players in this world.");
}
}
@ -212,13 +213,15 @@ public class Actions {
if (file != null) {
file = appendPNGFileExtensionIfNecessary(file);
if (file.exists() && !file.isFile()) {
mainWindow.displayError(
"Unable to write capture image, because the target exists but is not a file: "
+ file.getAbsolutePath());
String message = "Unable to write capture image, because the target exists but is not a file: "
+ file.getAbsolutePath();
AmidstLogger.warn(message);
mainWindow.displayError(message);
} else if (!canWriteToFile(file)) {
mainWindow.displayError(
"Unable to write capture image, because you have no writing permissions: "
+ file.getAbsolutePath());
String message = "Unable to write capture image, because you have no writing permissions: "
+ file.getAbsolutePath();
AmidstLogger.warn(message);
mainWindow.displayError(message);
} else if (!file.exists() || mainWindow.askToConfirm(
"Replace file?",
"File already exists. Do you want to replace it?\n" + file.getAbsolutePath() + "")) {

View File

@ -292,8 +292,8 @@ public class MainWindow {
}
@CalledOnlyBy(AmidstThread.EDT)
public void displayException(Exception exception) {
AmidstMessageBox.displayError(frame, "Error", exception);
public void displayException(Exception e) {
AmidstMessageBox.displayError(frame, "Error", e);
}
@CalledOnlyBy(AmidstThread.EDT)

View File

@ -39,7 +39,7 @@ public class UpdatePrompt {
return new UpdatePrompt(
currentVersion,
workerExecutor,
exception -> mainWindow.displayException(exception),
e -> mainWindow.displayException(e),
() -> mainWindow.displayMessage(TITLE, NO_UPDATES_AVAILABLE),
message -> mainWindow.askToConfirm(TITLE, message));
}
@ -55,7 +55,7 @@ public class UpdatePrompt {
return new UpdatePrompt(
currentVersion,
workerExecutor,
exception -> AmidstMessageBox.displayError(TITLE, exception),
e -> AmidstMessageBox.displayError(TITLE, e),
() -> AmidstMessageBox.displayInfo(TITLE, NO_UPDATES_AVAILABLE),
message -> askToConfirmDirectly(message));
}
@ -102,13 +102,7 @@ public class UpdatePrompt {
@CalledOnlyBy(AmidstThread.EDT)
private void onCheckFailed(Exception e) {
AmidstLogger.warn("unable to check for updates");
displayError(e);
}
@CalledOnlyBy(AmidstThread.EDT)
private void displayError(Exception e) {
AmidstLogger.warn(e);
AmidstLogger.warn(e, "unable to check for updates");
exceptionConsumer.accept(e);
}
@ -118,7 +112,8 @@ public class UpdatePrompt {
try {
openURL(new URI(updateInformation.getDownloadUrl()));
} catch (IOException | UnsupportedOperationException | URISyntaxException e) {
displayError(e);
AmidstLogger.warn(e);
exceptionConsumer.accept(e);
}
}
}
@ -134,6 +129,7 @@ public class UpdatePrompt {
} else if (newVersion.isSameVersionButOldPreReleaseAndNewStable(currentVersion)) {
return askToConfirm(createMessage(message, newVersion, "stable"));
} else {
AmidstLogger.info(NO_UPDATES_AVAILABLE);
noUpdatesDisplayer.run();
return false;
}

View File

@ -18,6 +18,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.file.json.filter.WorldFilterJson_MatchAll;
import amidst.mojangapi.world.WorldSeed;
import amidst.mojangapi.world.WorldType;
@ -111,6 +112,7 @@ public class SeedSearcherWindow {
WorldType worldType = seedSearcherConfiguration.getWorldType();
seedSearcher.search(seedSearcherConfiguration, worldSeed -> seedFound(worldSeed, worldType));
} else {
AmidstLogger.warn("invalid configuration");
mainWindow.displayError("invalid configuration");
}
}