mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 09:56:37 -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 javafx.application.Platform;
|
||||
import javafx.scene.control.Dialog;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -56,21 +57,14 @@ public final class Minosoft {
|
||||
|
||||
taskWorker.setFatalError((exception) -> {
|
||||
Log.fatal("Critical error occurred while preparing. Exit");
|
||||
if (StartProgressWindow.toolkitLatch.getCount() == 2) {
|
||||
try {
|
||||
try {
|
||||
if (StartProgressWindow.toolkitLatch.getCount() == 2) {
|
||||
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
|
||||
StartProgressWindow.hideDialog();
|
||||
@ -80,7 +74,10 @@ public final class Minosoft {
|
||||
// Do not translate this, translations might fail to load...
|
||||
dialog.setTitle("Critical Error");
|
||||
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.getIcons().add(GUITools.logo);
|
||||
|
@ -187,7 +187,7 @@ public class Configuration {
|
||||
return config;
|
||||
}
|
||||
|
||||
private void migrateConfiguration() {
|
||||
private void migrateConfiguration() throws ConfigMigrationException {
|
||||
int configVersion = getInt(ConfigurationPaths.IntegerPaths.GENERAL_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++) {
|
||||
@ -199,10 +199,10 @@ public class Configuration {
|
||||
|
||||
}
|
||||
|
||||
private void migrateConfiguration(int nextVersion) {
|
||||
private void migrateConfiguration(int nextVersion) throws ConfigMigrationException {
|
||||
switch (nextVersion) {
|
||||
// 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();
|
||||
}
|
||||
|
||||
public static void createParentFolderIfNotExist(String file) {
|
||||
createParentFolderIfNotExist(new File(file));
|
||||
public static boolean createParentFolderIfNotExist(String file) {
|
||||
return createParentFolderIfNotExist(new File(file));
|
||||
}
|
||||
|
||||
public static void createParentFolderIfNotExist(File file) {
|
||||
file.getParentFile().mkdirs();
|
||||
public static boolean createParentFolderIfNotExist(File file) {
|
||||
return file.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
public static String generateRandomString(int length) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user