Source:
<code>public Response toResponse(final Exception exception) { if (exception instanceof IllegalSourceException) { return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(createErrorEntity(HttpServletResponse.SC_BAD_REQUEST, exception.getMessage())).build(); } if (exception instanceof IllegalArgumentException) { return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(createErrorEntity(HttpServletResponse.SC_BAD_REQUEST, exception.getMessage())).build(); } if (exception instanceof ParamException && ((ParamException) exception).getParameterName().equals("objectType")) { return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(createErrorEntity(HttpServletResponse.SC_BAD_REQUEST, "unknown type")).build(); } <START> if (exception instanceof NotFoundException) { <END> return createErrorResponse(Response.Status.NOT_FOUND, exception.getMessage()); } if (exception instanceof BadRequestException) { return createErrorResponse(Response.Status.BAD_REQUEST, exception.getMessage()); } if (exception instanceof WebApplicationException) { return ((WebApplicationException) exception).getResponse(); } if (exception instanceof JsonProcessingException) { return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(createErrorEntity(HttpServletResponse.SC_BAD_REQUEST, exception.getMessage())).build(); } if (exception instanceof EmptyResultDataAccessException) { return Response.status(HttpServletResponse.SC_NOT_FOUND).entity(createErrorEntity(HttpServletResponse.SC_NOT_FOUND, "not found")).build(); } if (exception instanceof QueryException) { return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(createErrorEntity(HttpServletResponse.SC_BAD_REQUEST, exception.getMessage())).build(); } if (exception instanceof IllegalStateException) { return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(createErrorEntity(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, exception.getMessage())).build(); } LOGGER.error("Unexpected", exception); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(createErrorEntity(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, exception.getMessage())).build(); }</code><technical_language>NotFound BadRequest covered WebApplicationException catch-all immediately below</technical_language>

Target:
public Response toResponse(final Exception exception) { if (exception instanceof IllegalSourceException) { return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(createErrorEntity(HttpServletResponse.SC_BAD_REQUEST, exception.getMessage())).build(); } if (exception instanceof IllegalArgumentException) { return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(createErrorEntity(HttpServletResponse.SC_BAD_REQUEST, exception.getMessage())).build(); } if (exception instanceof ParamException) { String parameterName = ((ParamException) exception).getParameterName(); return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(createErrorEntity(HttpServletResponse.SC_BAD_REQUEST, "unknown " + parameterName)).build(); } if (exception instanceof NotFoundException) { return createErrorResponse(Response.Status.NOT_FOUND, exception.getMessage()); } if (exception instanceof BadRequestException) { return createErrorResponse(Response.Status.BAD_REQUEST, exception.getMessage()); } if (exception instanceof WebApplicationException) { LOGGER.warn("unexpected error " + exception.getMessage()); return ((WebApplicationException) exception).getResponse(); } if (exception instanceof JsonProcessingException) { return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(createErrorEntity(HttpServletResponse.SC_BAD_REQUEST, exception.getMessage())).build(); } if (exception instanceof EmptyResultDataAccessException) { return Response.status(HttpServletResponse.SC_NOT_FOUND).entity(createErrorEntity(HttpServletResponse.SC_NOT_FOUND, "not found")).build(); } if (exception instanceof QueryException) { return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(createErrorEntity(HttpServletResponse.SC_BAD_REQUEST, exception.getMessage())).build(); } if (exception instanceof IllegalStateException) { return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(createErrorEntity(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, exception.getMessage())).build(); } LOGGER.error("Unexpected", exception); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(createErrorEntity(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, exception.getMessage())).build(); }