private Object buildErrorResponse(Throwable ex, Request request) {
        if (ex instanceof IOException) {
            return ex;
        }
        Builder builder = new Builder();
        builder.code(HttpStatus.SC_INTERNAL_SERVER_ERROR);
        builder.message(ex.getMessage());
        builder.protocol(Protocol.HTTP_1_1);
        builder.request(request);
        return builder.build();
    }
@Test
    public void buildErrorResponseTest() throws IOException {
        Optional<Method> method = ReflectUtils.findMethod(OkHttp3ClientInterceptor.class, "buildErrorResponse",
                new Class[] {Exception.class, Request.class});
        Request request = createRequest(url);
        Exception ex = new Exception("error");
        if (method.isPresent()) {
            Optional<Object> response = ReflectUtils
                    .invokeMethod(interceptor, method.get(), new Object[] {ex, request});
            Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, ((Response)response.get()).code());
        }
    }