  @Test public void enqueueLogsRequestCreationFailure() {

    MockWebServer server = new MockWebServer();
    final AtomicReference<Throwable> failureRef = new AtomicReference<>();
    Retrofit retrofit = new Retrofit.Builder().baseUrl(server.url("/"))
        .addCallAdapterFactory(
            new LoggingCallAdapterFactory(new LoggingCallAdapterFactory.Logger() {
              @Override public <T> void onResponse(Call<T> call, Response<T> response) {
                throw new AssertionError();
              }

              @Override public <T> void onFailure(Call<T> call, Throwable t) {
                failureRef.set(t);
              }
            }))
        .addConverterFactory(new ToStringConverterFactory())
        .build();
    Service service = retrofit.create(Service.class);

    server.enqueue(new MockResponse());

    Object a = new Object() {
      @Override public String toString() {
        throw new RuntimeException("Broken!");
      }
    };
    Call<Void> call = service.getWithPath(a);
    call.enqueue(new Callback<Void>() {
      @Override public void onResponse(Call<Void> call, Response<Void> response) {
        throw new AssertionError();
      }

      @Override public void onFailure(Call<Void> call, Throwable t) {
      }
    });
    assertThat(failureRef.get()).isInstanceOf(RuntimeException.class);
    assertThat(failureRef.get()).hasMessageThat().isEqualTo("Broken!");
  }