Commit f58d021c authored by Carl Gützkow's avatar Carl Gützkow
Browse files

enhance: better error messages and catching for importing army and adding image

parent 9f10703a
Pipeline #183934 passed with stages
in 44 seconds
......@@ -46,7 +46,8 @@ public class App extends Application {
String imagePath = Paths.get(currentPath.toString(), "src","main","resources","icons", "wargames-logo.png").toString();
Image image = new Image(imagePath);
stage.getIcons().add(image);
} catch(IllegalArgumentException e) {
} catch(IllegalArgumentException | NullPointerException e) {
e.printStackTrace();
new DialogBoxBuilder(ERROR).setMessage("Failed loading in image. \nError message: " + e.getMessage())
.build().show();
}
......
......@@ -107,7 +107,7 @@ public class BattleController implements Initializable {
Path currentPath = Paths.get("").toAbsolutePath();
String imagePath = Paths.get(currentPath.toString(), "src","main","resources","icons", "corrupt-file.png").toString();
dialogBoxBuilder.setImage(imagePath);
} catch(Exception e) {
} catch(IllegalArgumentException | NullPointerException e) {
new DialogBoxBuilder(ERROR).setMessage("Failed loading in image. \nError message: " + e.getMessage())
.build().show();
}
......
......@@ -101,6 +101,8 @@ public class ArmyFileHandler {
int health = Integer.parseInt(unit[2].trim());
army.addUnit(unitFactory.createUnit(unitType, name, health));
} catch (NumberFormatException e) {
readLinesSkipped.add("Line \"" + line + "\" skipped because health is not valid number because \" " + e.getMessage() + " \"");
} catch (IllegalArgumentException e) {
readLinesSkipped.add("Line \"" + line + "\" skipped because \"" + e.getMessage() + "\"");
} catch (ArrayIndexOutOfBoundsException e) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment