Skip to content

Commit c8aac3c

Browse files
author
ChachyDev
committed
Output error messages when using UI
1 parent 2964c1b commit c8aac3c

File tree

2 files changed

+19
-9
lines changed
  • src/main/java/club/chachy/multimc4forge/installer
  • user-interface/src/main/java/club/chachy/multimc4forge/ui

2 files changed

+19
-9
lines changed

src/main/java/club/chachy/multimc4forge/installer/Installers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static Installer getInstaller(File forgeJar) {
2626
}
2727

2828
if (installer == null) {
29-
throw new IllegalStateException("There are no installers currently available for the provided jar...");
29+
throw new IllegalStateException("There are no installers currently available for the provided jar, is it a Forge jar...?");
3030
}
3131

3232
return installer;

user-interface/src/main/java/club/chachy/multimc4forge/ui/UI.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,28 @@
1010
import java.io.File;
1111

1212
public class UI {
13-
public static void main(String[] args) throws Throwable {
14-
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
13+
public static void main(String[] args) {
14+
try {
15+
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
1516

16-
File forgeJar = getFile(new JFileChooser(), "Please select a Forge INSTALLER jar", "You MUST provide a Forge Installer jar...", new JarFilter(), new ZipFilter());
17+
File forgeJar = getFile(new JFileChooser(), "Please select a Forge INSTALLER jar", "You MUST provide a Forge Installer jar...", new JarFilter(), new ZipFilter());
1718

18-
if (forgeJar != null) {
19-
File multiMcDirectory = getFile(new JFileChooser(), "Please provide your Multi", "You MUST provide a MultiMC install directory", new DirectoryFilter());
19+
if (forgeJar != null) {
20+
File multiMcDirectory = getFile(new JFileChooser(), "Please provide your Multi", "You MUST provide a MultiMC install directory", new DirectoryFilter());
2021

21-
if (multiMcDirectory != null) {
22-
File location = Installers.getInstaller(forgeJar).install(multiMcDirectory, forgeJar);
23-
JOptionPane.showMessageDialog(null, "Successfully installed Forge to " + location.getAbsolutePath() + "! Make sure to restart MultiMC if it was already opened", "Success! :)", JOptionPane.PLAIN_MESSAGE);
22+
if (multiMcDirectory != null) {
23+
File location = Installers.getInstaller(forgeJar).install(multiMcDirectory, forgeJar);
24+
JOptionPane.showMessageDialog(null, "Successfully installed Forge to " + location.getAbsolutePath() + "! Make sure to restart MultiMC if it was already opened", "Success! :)", JOptionPane.PLAIN_MESSAGE);
25+
}
2426
}
27+
} catch (Throwable t) {
28+
String message = t.getMessage();
29+
30+
if (message != null) {
31+
JOptionPane.showMessageDialog(null, message, "An error occurred :(", JOptionPane.ERROR_MESSAGE);
32+
}
33+
34+
t.printStackTrace();
2535
}
2636
}
2737

0 commit comments

Comments
 (0)