Skip to content

Commit

Permalink
Enhance error display message in server-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Nov 14, 2023
1 parent bbb38fb commit 6a43882
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,27 +254,27 @@ private void handleException(Exception e, HttpServletResponse resp) throws IOExc
|| e instanceof ClientSleepingException) {
LOG.warn("Invalid request", e);
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
resp.getWriter().append("Invalid request:").append(e.getMessage()).flush();
resp.getWriter().append("Invalid request: ").append(e.getMessage()).flush();
} else if (e instanceof RequestRejectedException) {
LOG.warn("Request rejected", e);
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
resp.getWriter().append("Request rejected:").append(e.getMessage()).flush();
resp.getWriter().append("Request rejected: ").append(e.getMessage()).flush();
} else if (e instanceof RequestCanceledException) {
LOG.warn("Request cancelled", e);
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
resp.getWriter().append("Request cancelled:").append(e.getMessage()).flush();
resp.getWriter().append("Request cancelled: ").append(e.getMessage()).flush();
} else if (e instanceof InvalidResponseException) {
LOG.warn("Invalid response", e);
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
resp.getWriter().append("Invalid Response:").append(e.getMessage()).flush();
resp.getWriter().append("Invalid Response: ").append(e.getMessage()).flush();
} else if (e instanceof InterruptedException) {
LOG.warn("Thread Interrupted", e);
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
resp.getWriter().append("Thread Interrupted:").append(e.getMessage()).flush();
resp.getWriter().append("Thread Interrupted: ").append(e.getMessage()).flush();
} else {
LOG.warn("Unexpected exception", e);
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
resp.getWriter().append("Unexpected exception:").append(e.getMessage()).flush();
resp.getWriter().append("Unexpected exception: ").append(e.getMessage()).flush();
}
}

Expand Down

0 comments on commit 6a43882

Please sign in to comment.