@VisibleForTesting
  RegistryErrorException newRegistryErrorException(ResponseException responseException) {
    RegistryErrorExceptionBuilder registryErrorExceptionBuilder =
        new RegistryErrorExceptionBuilder(
            registryEndpointProvider.getActionDescription(), responseException);
    if (responseException.getContent() != null) {
      try {
        ErrorResponseTemplate errorResponse =
            JsonTemplateMapper.readJson(
                responseException.getContent(), ErrorResponseTemplate.class);
        for (ErrorEntryTemplate errorEntry : errorResponse.getErrors()) {
          registryErrorExceptionBuilder.addReason(errorEntry);
        }
      } catch (IOException ex) {
        registryErrorExceptionBuilder.addReason(
            "registry returned error code "
                + responseException.getStatusCode()
                + "; possible causes include invalid or wrong reference. Actual error output follows:\n"
                + responseException.getContent()
                + "\n");
      }
    } else {
      registryErrorExceptionBuilder.addReason(
          "registry returned error code "
              + responseException.getStatusCode()
              + " but did not return any details; possible causes include invalid or wrong reference, or proxy/firewall/VPN interfering \n");
    }
    return registryErrorExceptionBuilder.build();
  }
Calls the registry endpoint with a certain {@link URL}.

@param url the endpoint URL to call
@return an object representing the response
@throws IOException for most I/O exceptions when making the request
@throws RegistryException for known exceptions when interacting with the registry
jib-core/src/main/java/com/google/cloud/tools/jib/registry/RegistryEndpointCaller.java