Skip to content

Commit

Permalink
improved error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke460 committed Jan 19, 2022
1 parent 07ebcd4 commit 6e5499c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
Expand Down
17 changes: 13 additions & 4 deletions src/execution/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import userInterface.Menu;

import javax.swing.*;

public class Main {

public static void main(String[] args) {
Expand All @@ -12,13 +14,20 @@ public static void main(String[] args) {
SimpleLogger.infoLog("reading '" + JSON_CONFIG_PATH + "'...");

org.json.JSONObject config = Utility.readConfiguration(JSON_CONFIG_PATH);

if(config == null) return;

// Open Menu
SimpleLogger.infoLog("opening Menu...");
Menu menu = new Menu();
menu.showMenu(config);

try {
Menu menu = new Menu();
menu.showMenu(config);
} catch (org.json.JSONException e) {
JOptionPane.showMessageDialog(null, "Something went wrong:\nUnable to load the configuration file '" + JSON_CONFIG_PATH + "'.\nError details: " + e.getMessage());
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Something went wrong:\nError details: " + e.getMessage());
}

}

Expand Down
2 changes: 1 addition & 1 deletion src/execution/Utility.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static org.json.JSONObject readConfiguration(String path){
config = new org.json.JSONObject(new String(Files.readAllBytes(Paths.get(path))));
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Error: unable to read '" + path + "' file.");
JOptionPane.showMessageDialog(null, "Something went wrong:\nError details: unable to read '" + path + "' file.");
return null;
}
return config;
Expand Down

0 comments on commit 6e5499c

Please sign in to comment.