Skip to content

Commit

Permalink
Report number format exception
Browse files Browse the repository at this point in the history
  • Loading branch information
slominskir committed Dec 9, 2024
1 parent e543b52 commit cc1e206
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
LOGGER.log(Level.WARNING, "Unable to parse notifications parameter");
}

List<DestinationAuthorization> destinationAuthorizationList =
convertDestinationAuthorizationList(request);

try {
List<DestinationAuthorization> destinationAuthorizationList =
convertDestinationAuthorizationList(request);

authorizationFacade.saveAuthorization(comments, destinationAuthorizationList);
} catch (UserFriendlyException e) {
errorReason = e.getUserMessage();
Expand Down Expand Up @@ -171,7 +171,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
}

private List<DestinationAuthorization> convertDestinationAuthorizationList(
HttpServletRequest request) {
HttpServletRequest request) throws UserFriendlyException {
List<DestinationAuthorization> destinationAuthorizationList = new ArrayList<>();
String[] modeArray = request.getParameterValues("mode[]");
String[] limitStrArray = request.getParameterValues("limit[]");
Expand Down Expand Up @@ -204,8 +204,13 @@ private List<DestinationAuthorization> convertDestinationAuthorizationList(
da.setCwLimit(null);
} else if (limitStr != null && !limitStr.equals("") && !limitStr.equals("N/A")) {
limitStr = limitStr.replaceAll(",", ""); // Remove commas
BigDecimal limit = new BigDecimal(limitStr);
da.setCwLimit(limit);

try {
BigDecimal limit = new BigDecimal(limitStr);
da.setCwLimit(limit);
} catch (NumberFormatException e) {
throw new UserFriendlyException("limit must be a number", e);
}
}

String comments = commentsArray[i];
Expand Down

0 comments on commit cc1e206

Please sign in to comment.