public boolean fileExists(String path) throws IOException, InvalidTokenException {
    String url;
    try {
      url =
          getUriBuilder()
              .setPath(API_PATH_PREFIX + "/mounts/primary/files/info")
              .setParameter("path", path)
              .build()
              .toString();
    } catch (URISyntaxException e) {
      throw new IllegalStateException("Could not produce url.", e);
    }

    Request.Builder requestBuilder = getRequestBuilder(url);

    try (Response response = getResponse(requestBuilder)) {
      int code = response.code();
      if (code == 200) {
        return true;
      }
      if (code == 404) {
        return false;
      }
      throw new KoofrClientIOException(response);
    }
  }
@Test
  public void testFileExistsError() {
    server.enqueue(new MockResponse().setResponseCode(500).setBody("Internal error"));

    KoofrClientIOException caughtExc =
        assertThrows(
            KoofrClientIOException.class, () -> client.fileExists("/path/to/file"));

    assertNotNull(caughtExc);
    assertEquals(
        "Got error code: 500 message: Server Error body: Internal error", caughtExc.getMessage());

    assertEquals(1, server.getRequestCount());
  }