Skip to content

Commit bbd8aea

Browse files
committed
Handled exception for wrong query params
1 parent 976e5ba commit bbd8aea

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/main/java/edu/tamu/app/controller/NotificationController.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import static edu.tamu.framework.enums.BusinessValidationType.NONEXISTS;
88
import static edu.tamu.framework.enums.BusinessValidationType.UPDATE;
99

10+
import java.util.ArrayList;
1011
import java.util.List;
1112

1213
import org.springframework.beans.factory.annotation.Autowired;
@@ -76,8 +77,12 @@ public String getActiveNotifications(@RequestParam(value = "location", defaultVa
7677
if (locationString.equals("ALL")) {
7778
notificationList = notificationRepo.findByIsActive(true);
7879
} else {
79-
notificationList = notificationRepo.findByIsActiveAndLocations(true, NotificationLocation.valueOf(locationString));
80-
80+
try {
81+
NotificationLocation location = NotificationLocation.valueOf(locationString);
82+
notificationList = notificationRepo.findByIsActiveAndLocations(true, location);
83+
} catch (IllegalArgumentException e) {
84+
notificationList = new ArrayList<Notification>();
85+
}
8186
}
8287
for (Notification notification : notificationList) {
8388
notificationString += "<p>" + notification.getBody() + "</p>";

0 commit comments

Comments
 (0)