Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Carl Johan Gützkow
Wargames
Commits
f58d021c
Commit
f58d021c
authored
May 22, 2022
by
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
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/edu/ntnu/idatt2001/carljgu/client/App.java
View file @
f58d021c
...
...
@@ -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
();
}
...
...
src/main/java/edu/ntnu/idatt2001/carljgu/client/controllers/BattleController.java
View file @
f58d021c
...
...
@@ -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
|
NullPointer
Exception
e
)
{
new
DialogBoxBuilder
(
ERROR
).
setMessage
(
"Failed loading in image. \nError message: "
+
e
.
getMessage
())
.
build
().
show
();
}
...
...
src/main/java/edu/ntnu/idatt2001/carljgu/filehandling/ArmyFileHandler.java
View file @
f58d021c
...
...
@@ -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
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment