Skip to content
Snippets Groups Projects
Commit 4c6fe37c authored by Harry Linrui XU's avatar Harry Linrui XU
Browse files

Potentially caught exception in the correct manner

parent f793ae51
No related branches found
No related tags found
5 merge requests!43Merging frontend-testing into master,!38"Made progressbar dynamic in accordance to spending. Added balance field....,!37Made the sub progress bars respond to changes in expense,!32Added input validation to add dialog boxes.,!31Added input validation to tableviews
......@@ -167,9 +167,11 @@ public class AddExpenseController {
private void addEventFilters() {
okBtn.addEventFilter(
ActionEvent.ACTION, event -> {
if (!validateInputs()) {
event.consume();
errorMsg.setOpacity(1);
try {
validateInputs();
} catch(IllegalArgumentException e) {
event.consume();
errorMsg.setOpacity(1);
}
});
}
......@@ -179,8 +181,7 @@ public class AddExpenseController {
Double.parseDouble(amountField.getText()), recurringBox.getValue(),
categoryBox.getValue(), datePicker.getValue());
} catch (IllegalArgumentException e) {
System.out.println("ok");
return false;
throw new IllegalArgumentException("Invalid input. Cannot instantiate expense", e);
}
return true;
}
......
......@@ -150,7 +150,9 @@ public class AddIncomeController {
private void addEventFilters() {
okBtn.addEventFilter(
ActionEvent.ACTION, event -> {
if (!validateInputs()) {
try {
validateInputs();
} catch(IllegalArgumentException e) {
event.consume();
errorMsg.setOpacity(1);
}
......@@ -162,8 +164,7 @@ public class AddIncomeController {
Double.parseDouble(amountField.getText()), recurringBox.getValue(),
categoryBox.getValue(), datePicker.getValue());
} catch (IllegalArgumentException e) {
System.out.println("ok");
return false;
throw new IllegalArgumentException("Invalid inputs. Cannot instantiate income", e);
}
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment