diff options
author | Gunther6070 <haydenhartman10@yahoo.com> | 2025-03-30 20:48:32 -0400 |
---|---|---|
committer | Gunther6070 <haydenhartman10@yahoo.com> | 2025-03-30 20:48:32 -0400 |
commit | eb09f05ca697a3a6d3587f9278e332056bfd6f66 (patch) | |
tree | 3dfaf23ed404710f955471515870f54d20c693a4 | |
parent | 197be103d02db808b0e6bf8a1d1369e3d7928c03 (diff) | |
download | JellySolutions-eb09f05ca697a3a6d3587f9278e332056bfd6f66.tar.gz JellySolutions-eb09f05ca697a3a6d3587f9278e332056bfd6f66.tar.bz2 JellySolutions-eb09f05ca697a3a6d3587f9278e332056bfd6f66.zip |
Modified controllers to return error text when catching errors. Also added additional error checking to CupboardService for physical needs.
-rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java index 4dcfcad..a86fe28 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java @@ -35,6 +35,8 @@ public class CupboardService { if (maxGoal <= 0) { throw new IllegalArgumentException("Max Goal must be greater than zero"); + } else if (goalType.equals(Need.GoalType.PHYSICAL) && maxGoal % 1 != 0) { + throw new IllegalArgumentException("Cannot have non whole number value for physical goal"); } for (Need searchNeed : cupboardDAO.getNeeds()) { @@ -95,6 +97,8 @@ public class CupboardService { } if (need.getMaxGoal() <= 0) { throw new IllegalArgumentException("Goal must be greater than 0"); + } else if (need.getType().equals(Need.GoalType.PHYSICAL) && need.getMaxGoal() % 1 != 0) { + throw new IllegalArgumentException("Cannot have non whole number value for physical goal"); } return cupboardDAO.updateNeed(need); } |