Skip to content

Commit

Permalink
poolgroup: error code update
Browse files Browse the repository at this point in the history
Motivation: Update from 500 to 400 when user enters a pool group name that doesn't exist.

Modification: Add an instance of the NoSuchElementException class to throw a 400 - bad request.

Result: End user will get a more accurate response.

Acked-by: Tigran Mkrtchyan
Target: master
Require-book: no
Require-notes: no
  • Loading branch information
khys95 committed Sep 23, 2024
1 parent c2406da commit f260a34
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
import com.google.common.base.Throwables;
import java.net.URI;
import java.util.NoSuchElementException;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.NotFoundException;
Expand Down Expand Up @@ -60,7 +61,7 @@ public Response toResponse(Exception e) {
// Unfortunately Jackson builds multiline messages, we work around this.
return buildResponse(Response.Status.BAD_REQUEST,
"Unable to interpret JSON: " + firstLineOf(e.getMessage()));
} else if (e instanceof BadRequestException) {
} else if (e instanceof BadRequestException || e instanceof NoSuchElementException) {
return buildResponse(Response.Status.BAD_REQUEST,
getMessage(e, "Bad request"));
} else if (e instanceof NotFoundException) {
Expand Down

0 comments on commit f260a34

Please sign in to comment.