@Override
    public Response toResponse(Throwable e) {
        if (log.isDebugEnabled()) {
            log.debug("Uncaught exception in REST call: ", e);
        } else if (log.isInfoEnabled()) {
            log.info("Uncaught exception in REST call: {}", e.getMessage());
        }
        if (e instanceof NotFoundException) {
            return buildResponse(Response.Status.NOT_FOUND, e);
        } else if (e instanceof InvalidRequestException) {
            return buildResponse(Response.Status.BAD_REQUEST, e);
        } else if (e instanceof InvalidTypeIdException) {
            return buildResponse(Response.Status.NOT_IMPLEMENTED, e);
        } else if (e instanceof JsonMappingException) {
            return buildResponse(Response.Status.BAD_REQUEST, e);
        } else if (e instanceof ClassNotFoundException) {
            return buildResponse(Response.Status.NOT_IMPLEMENTED, e);
        } else if (e instanceof SerializationException) {
            return buildResponse(Response.Status.BAD_REQUEST, e);
        } else if (e instanceof RequestConflictException) {
            return buildResponse(Response.Status.CONFLICT, e);
        } else {
            return buildResponse(Response.Status.INTERNAL_SERVER_ERROR, e);
        }
    }
@Test
    public void testToResponseNotFound() {
        RestExceptionMapper mapper = new RestExceptionMapper();
        Response resp = mapper.toResponse(new NotFoundException());
        assertEquals(resp.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
    }