Skip to content

Commit

Permalink
map clientExceptionErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
mwangggg committed Feb 6, 2024
1 parent a8b7227 commit 17f6528
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/main/java/io/cryostat/rules/Rules.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,21 @@ public RestResponse<V2Response> create(Rule rule) {
}

@ServerExceptionMapper
public RestResponse<V2Response> mapException(RuleExistsException e) {
public RestResponse<V2Response> mapException(ClientErrorException e) {
if (e instanceof RuleExistsException) {
return ResponseBuilder.create(
Response.Status.CONFLICT,
V2Response.json(Response.Status.CONFLICT, e.getMessage()))
.build();
} else if (e instanceof NotFoundException) {
return ResponseBuilder.create(
Response.Status.NOT_FOUND,
V2Response.json(Response.Status.NOT_FOUND, e.getMessage()))
.build();
}
return ResponseBuilder.create(
Response.Status.CONFLICT,
V2Response.json(Response.Status.CONFLICT, e.getMessage()))
Response.Status.BAD_REQUEST,
V2Response.json(Response.Status.BAD_REQUEST, e.getMessage()))
.build();
}

Expand Down

0 comments on commit 17f6528

Please sign in to comment.