mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 10:25:06 -04:00
startup error: make error copyable, improve code
This commit is contained in:
parent
e805f72e7c
commit
f9c791cf39
@ -35,6 +35,7 @@ import de.bixilon.minosoft.util.task.Task;
|
|||||||
import de.bixilon.minosoft.util.task.TaskImportance;
|
import de.bixilon.minosoft.util.task.TaskImportance;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.scene.control.Dialog;
|
import javafx.scene.control.Dialog;
|
||||||
|
import javafx.scene.control.TextArea;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -56,21 +57,14 @@ public final class Minosoft {
|
|||||||
|
|
||||||
taskWorker.setFatalError((exception) -> {
|
taskWorker.setFatalError((exception) -> {
|
||||||
Log.fatal("Critical error occurred while preparing. Exit");
|
Log.fatal("Critical error occurred while preparing. Exit");
|
||||||
if (StartProgressWindow.toolkitLatch.getCount() == 2) {
|
try {
|
||||||
try {
|
if (StartProgressWindow.toolkitLatch.getCount() == 2) {
|
||||||
StartProgressWindow.start();
|
StartProgressWindow.start();
|
||||||
} catch (InterruptedException e2) {
|
|
||||||
e2.printStackTrace();
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (StartProgressWindow.toolkitLatch.getCount() > 0) {
|
|
||||||
try {
|
|
||||||
StartProgressWindow.toolkitLatch.await();
|
|
||||||
} catch (InterruptedException e2) {
|
|
||||||
e2.printStackTrace();
|
|
||||||
System.exit(1);
|
|
||||||
}
|
}
|
||||||
|
StartProgressWindow.toolkitLatch.await();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.exit(1);
|
||||||
}
|
}
|
||||||
// hide all other gui parts
|
// hide all other gui parts
|
||||||
StartProgressWindow.hideDialog();
|
StartProgressWindow.hideDialog();
|
||||||
@ -80,7 +74,10 @@ public final class Minosoft {
|
|||||||
// Do not translate this, translations might fail to load...
|
// Do not translate this, translations might fail to load...
|
||||||
dialog.setTitle("Critical Error");
|
dialog.setTitle("Critical Error");
|
||||||
dialog.setHeaderText("An error occurred while starting Minosoft");
|
dialog.setHeaderText("An error occurred while starting Minosoft");
|
||||||
dialog.setContentText(exception.getClass().getCanonicalName() + ": " + exception.getLocalizedMessage());
|
TextArea text = new TextArea(exception.getClass().getCanonicalName() + ": " + exception.getLocalizedMessage());
|
||||||
|
text.setEditable(false);
|
||||||
|
text.setWrapText(true);
|
||||||
|
dialog.getDialogPane().setContent(text);
|
||||||
|
|
||||||
Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
|
Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
|
||||||
stage.getIcons().add(GUITools.logo);
|
stage.getIcons().add(GUITools.logo);
|
||||||
|
@ -187,7 +187,7 @@ public class Configuration {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void migrateConfiguration() {
|
private void migrateConfiguration() throws ConfigMigrationException {
|
||||||
int configVersion = getInt(ConfigurationPaths.IntegerPaths.GENERAL_CONFIG_VERSION);
|
int configVersion = getInt(ConfigurationPaths.IntegerPaths.GENERAL_CONFIG_VERSION);
|
||||||
Log.info(String.format("Migrating config from version %d to %d", configVersion, LATEST_CONFIG_VERSION));
|
Log.info(String.format("Migrating config from version %d to %d", configVersion, LATEST_CONFIG_VERSION));
|
||||||
for (int nextVersion = configVersion + 1; nextVersion <= LATEST_CONFIG_VERSION; nextVersion++) {
|
for (int nextVersion = configVersion + 1; nextVersion <= LATEST_CONFIG_VERSION; nextVersion++) {
|
||||||
@ -199,10 +199,10 @@ public class Configuration {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void migrateConfiguration(int nextVersion) {
|
private void migrateConfiguration(int nextVersion) throws ConfigMigrationException {
|
||||||
switch (nextVersion) {
|
switch (nextVersion) {
|
||||||
// ToDo
|
// ToDo
|
||||||
default -> throw new IllegalArgumentException("Can not migrate config: Unknown config version " + nextVersion);
|
default -> throw new ConfigMigrationException("Can not migrate config: Unknown config version " + nextVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,12 +253,12 @@ public final class Util {
|
|||||||
return new ThreadFactoryBuilder().setNameFormat(threadName + "#%d").build();
|
return new ThreadFactoryBuilder().setNameFormat(threadName + "#%d").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createParentFolderIfNotExist(String file) {
|
public static boolean createParentFolderIfNotExist(String file) {
|
||||||
createParentFolderIfNotExist(new File(file));
|
return createParentFolderIfNotExist(new File(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createParentFolderIfNotExist(File file) {
|
public static boolean createParentFolderIfNotExist(File file) {
|
||||||
file.getParentFile().mkdirs();
|
return file.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String generateRandomString(int length) {
|
public static String generateRandomString(int length) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user