Skip to content

Commit

Permalink
use Response.Status.Family.CLIENT_ERROR to check
Browse files Browse the repository at this point in the history
  • Loading branch information
liyaqin1 committed Jul 25, 2023
1 parent a3e2d46 commit 0c97f77
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public Response toResponse(Throwable t) {
PrintWriter pw = new PrintWriter(sw);
t.printStackTrace(pw);
sb.append("\n").append(sw.toString());
if (t.getMessage().contains("HTTP 4")) {
final Response response = ((WebApplicationException) t).getResponse();
Response.Status.Family family = response.getStatusInfo().getFamily();
if (family.equals(Response.Status.Family.CLIENT_ERROR)) {
return Response.status(Response.Status.BAD_REQUEST).entity(sb.toString()).build();
} else {
return Response.serverError().entity(sb.toString()).build();
Expand Down

0 comments on commit 0c97f77

Please sign in to comment.