Tabnine Logo
ClientException.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
com.aliyuncs.exceptions.ClientException
constructor

Best Java code snippets using com.aliyuncs.exceptions.ClientException.<init> (Showing top 20 results out of 315)

origin: com.aliyun/aliyun-java-sdk-core

  private ClientException newUnmarshalException(Class<?> clazz, String xmlContent, Exception e) {
    return new ClientException("SDK.UnmarshalFailed",
        "unmarshal response from xml content failed, clazz = " + clazz.getSimpleName() + ", origin response = " + xmlContent, e);
  }
}
origin: com.aliyun/aliyun-java-sdk-core

  private ClientException newUnmarshalException(Class<?> clazz, String content, Exception e) {
    return new ClientException("SDK.UnmarshalFailed",
        "unmarshal response from json content failed, clazz = " + clazz.getSimpleName() + ", origin response = " + content, e);
  }
}
origin: com.aliyun/aliyun-java-sdk-core

public String getHttpContentString() throws ClientException {
  String stringContent = "";
  if (this.httpContent != null) {
    try {
      if (this.encoding == null) {
        stringContent = new String(this.httpContent);
      } else {
        stringContent = new String(this.httpContent, this.encoding);
      }
    } catch (UnsupportedEncodingException exp) {
      throw new ClientException("SDK.UnsupportedEncoding", "Can not parse response due to unsupported encoding.");
    }
  }
  return stringContent;
}
origin: aliyun/aliyun-oss-java-sdk

@Override
public Credentials fetch(int retryTimes) throws ClientException {
  for (int i = 0; i <= retryTimes; i++) {
    try {
      return fetch();
    } catch (ClientException e) {
      if (i == retryTimes) {
        throw e;
      }
    }
  }
  throw new ClientException("Failed to connect ECS Metadata Service: Max retry times exceeded.");
}

origin: com.aliyun/aliyun-java-sdk-core

private void checkProductCode(ResolveEndpointRequest request) throws ClientException {
  boolean productCodeValid = false;
  for (EndpointResolverBase resolver : endpointResolvers) {
    if (resolver.isProductCodeValid(request)) {
      productCodeValid = true;
    }
  }
  if (!productCodeValid) {
    throw new ClientException(ErrorCodeConstant.SDK_ENDPOINT_RESOLVING_ERROR,
        String.format(ErrorMessageConstant.ENDPOINT_NO_PRODUCT, request.productCode));
  }
}
origin: com.aliyun/aliyun-java-sdk-core

private void checkRegionId(ResolveEndpointRequest request) throws ClientException {
  boolean regionIdValid = false;
  for (EndpointResolverBase resolver : endpointResolvers) {
    if (resolver.isRegionIdValid(request)) {
      regionIdValid = true;
    }
  }
  if (!regionIdValid) {
    throw new ClientException(ErrorCodeConstant.SDK_ENDPOINT_RESOLVING_ERROR,
        String.format(ErrorMessageConstant.INVALID_REGION_ID, request.regionId));
  }
}
origin: com.aliyun/aliyun-java-sdk-core

  public InstanceProfileCredentials fetch(int retryTimes) throws ClientException {
    for (int i = 0; i <= retryTimes; i++) {
      try {
        return fetch();
      } catch (ClientException e) {
        if (i == retryTimes) {
          throw e;
        }
      }
    }
    throw new ClientException("Failed to connect ECS Metadata Service: Max retry times exceeded.");
  }
}
origin: com.aliyun.oss/aliyun-sdk-oss

@Override
public Credentials fetch(int retryTimes) throws ClientException {
  for (int i = 0; i <= retryTimes; i++) {
    try {
      return fetch();
    } catch (ClientException e) {
      if (i == retryTimes) {
        throw e;
      }
    }
  }
  throw new ClientException("Failed to connect ECS Metadata Service: Max retry times exceeded.");
}

origin: com.aliyun/aliyun-java-sdk-core

public InstanceProfileCredentials fetch() throws ClientException {
  String jsonContent = getMetadata();
  JsonObject jsonObject = null;
  jsonObject = new JsonParser().parse(jsonContent).getAsJsonObject();
  if (jsonObject.has("Code") && jsonObject.has("AccessKeyId") && jsonObject.has("AccessKeySecret") && jsonObject
      .has("SecurityToken") && jsonObject.has("Expiration")) {
  } else {
    throw new ClientException("Invalid json got from ECS Metadata service.");
  }
  if (!"Success".equals(jsonObject.get("Code").getAsString())) {
    throw new ClientException(ECS_METADAT_FETCH_ERROR_MSG);
  }
  return new InstanceProfileCredentials(jsonObject.get("AccessKeyId").getAsString(), jsonObject.get(
      "AccessKeySecret").getAsString(), jsonObject.get("SecurityToken").getAsString(), jsonObject.get(
          "Expiration").getAsString(), DEFAULT_ECS_SESSION_TOKEN_DURATION_SECONDS);
}
origin: com.quhaodian.discover/discover-plug-alidayu

public Map<String, String> read(String response,String endpoint) throws ClientException{
  Element root;
  try {
    root = XmlUtils.getRootElementFromString(response);
    read(root, endpoint, false);
  } catch (ParserConfigurationException e) {
    new ClientException("SDK.InvalidXMLParser", e.toString());
  } catch (SAXException e) {
    new ClientException("SDK.InvalidXMLFormat", e.toString());
  } catch (IOException e) {
    new ClientException("SDK.InvalidContent", e.toString());
  }
  return map;
}
origin: com.aliyun/aliyun-java-sdk-core

@Override
public Map<String, String> read(String response, String endpoint) throws ClientException {
  Element root;
  try {
    root = XmlUtils.getRootElementFromString(response);
    read(root, endpoint, false);
  } catch (ParserConfigurationException e) {
    new ClientException("SDK.InvalidXMLParser", e.toString());
  } catch (SAXException e) {
    new ClientException("SDK.InvalidXMLFormat", e.toString());
  } catch (IOException e) {
    new ClientException("SDK.InvalidContent", e.toString());
  }
  return map;
}
origin: com.quhaodian.discover/discover-plug-alidayu

private String getResponseContent(HttpResponse httpResponse) throws ClientException {
  String stringContent = null;
  try {
    if (null == httpResponse.getEncoding()) {
      stringContent = new String(httpResponse.getContent());
    } else {
      stringContent = new String(httpResponse.getContent(), httpResponse.getEncoding());
    }
  } catch (UnsupportedEncodingException exp) {
    throw new ClientException("SDK.UnsupportedEncoding", "Can not parse response due to un supported encoding.");
  }
  return stringContent;
}
origin: com.quhaodian.discover/discover-plug-alidayu

  private String getResponseContent(HttpResponse httpResponse) throws ClientException {
    String stringContent = null;
    try {
      if (null == httpResponse.getEncoding()) {
        stringContent = new String(httpResponse.getContent());
      } else {
        stringContent = new String(httpResponse.getContent(), httpResponse.getEncoding());
      }
    } catch (UnsupportedEncodingException exp) {
      throw new ClientException("SDK.UnsupportedEncoding", "Can not parse response due to un supported encoding.");
    }
    return stringContent;
  }
}
origin: com.aliyun/aliyun-java-sdk-core

public String getMetadata() throws ClientException {
  HttpRequest request = new HttpRequest(credentialUrl.toString());
  request.setSysMethod(MethodType.GET);
  request.setSysConnectTimeout(connectionTimeoutInMilliseconds);
  request.setSysReadTimeout(connectionTimeoutInMilliseconds);
  HttpResponse response;
  try {
    response = CompatibleUrlConnClient.compatibleGetResponse(request);
  } catch (Exception e) {
    throw new ClientException("Failed to connect ECS Metadata Service: " + e.toString());
  }
  if (response.getStatus() != HttpURLConnection.HTTP_OK) {
    throw new ClientException(ECS_METADAT_FETCH_ERROR_MSG + " HttpCode=" + response.getStatus());
  }
  return new String(response.getHttpContent());
}
origin: com.quhaodian.discover/discover-plug-alidayu

private <T extends AcsResponse> T readResponse(Class<T> clasz, HttpResponse httpResponse, FormatType format) throws ClientException {
  Reader reader = ReaderFactory.createInstance(format);
  UnmarshallerContext context = new UnmarshallerContext();
  T response = null;
  String stringContent = getResponseContent(httpResponse);
  try {
    response = clasz.newInstance();
  } catch (Exception e) {
    throw new ClientException("SDK.InvalidResponseClass", "Unable to allocate " + clasz.getName() + " class");
  }
  String responseEndpoint = clasz.getName().substring(clasz.getName().lastIndexOf(".") + 1);
  context.setResponseMap(reader.read(stringContent, responseEndpoint));
  context.setHttpResponse(httpResponse);
  response.getInstance(context);
  return response;
}
origin: com.aliyun/aliyun-java-sdk-core

  @Override
  public String resolve(ResolveEndpointRequest request) throws ClientException {
    for (EndpointResolverBase resolver : endpointResolvers) {
      String endpoint = resolver.resolve(request);
      if (endpoint != null) {
        return endpoint;
      }
    }

    checkProductCode(request);
    checkRegionId(request);

    throw new ClientException(ErrorCodeConstant.SDK_ENDPOINT_RESOLVING_ERROR,
        String.format(ErrorMessageConstant.ENDPOINT_NO_REGION, request.regionId, request.productCode,
            getAvailableRegionsHint(request.productCode)));
  }
}
origin: com.quhaodian.discover/discover-plug-alidayu

@Override
public CommonResponse getCommonResponse(CommonRequest request)
    throws ServerException, ClientException {
  HttpResponse baseResponse = this.doAction(request);
  String data;
  try {
    data = new String(baseResponse.getContent(), "utf-8");
  } catch (UnsupportedEncodingException e) {
    throw new ClientException("SDK.CommonResponseEncodingError", "CommonResponse Encoding UnsupportedEncodingException.");
  }
  CommonResponse response = new CommonResponse();
  response.setData(data);
  response.setHttpResponse(baseResponse);
  return response;
}
origin: aliyun/aliyun-oss-java-sdk

@Override
public Credentials fetch() throws ClientException {
  URL url = buildUrl();
  HttpRequest request = new HttpRequest(url.toString());
  request.setMethod(MethodType.GET);
  request.setConnectTimeout(AuthUtils.DEFAULT_HTTP_SOCKET_TIMEOUT_IN_MILLISECONDS);
  request.setReadTimeout(AuthUtils.DEFAULT_HTTP_SOCKET_TIMEOUT_IN_MILLISECONDS);
  
  HttpResponse response = null;
  try {
    response = send(request);
  } catch (IOException e) {
    throw new ClientException("CredentialsFetcher.fetch exception: " + e);
  }
  
  return parse(response);
}

origin: com.aliyun.oss/aliyun-sdk-oss

@Override
public Credentials fetch() throws ClientException {
  URL url = buildUrl();
  HttpRequest request = new HttpRequest(url.toString());
  request.setMethod(MethodType.GET);
  request.setConnectTimeout(AuthUtils.DEFAULT_HTTP_SOCKET_TIMEOUT_IN_MILLISECONDS);
  request.setReadTimeout(AuthUtils.DEFAULT_HTTP_SOCKET_TIMEOUT_IN_MILLISECONDS);
  
  HttpResponse response = null;
  try {
    response = send(request);
  } catch (IOException e) {
    throw new ClientException("CredentialsFetcher.fetch exception: " + e);
  }
  
  return parse(response);
}

origin: com.quhaodian.discover/discover-plug-alidayu

private <T extends AcsResponse> T parseAcsResponse(Class<T> clasz, HttpResponse baseResponse)
    throws ServerException, ClientException {
  FormatType format = baseResponse.getContentType();
  if (baseResponse.isSuccess()) {
    return readResponse(clasz, baseResponse, format);
  } else {
    AcsError error = readError(baseResponse, format);
    if (500 <= baseResponse.getStatus()) {
      throw new ServerException(error.getErrorCode(), error.getErrorMessage(), error.getRequestId());
    } else {
      throw new ClientException(error.getErrorCode(), error.getErrorMessage(), error.getRequestId());
    }
  }
}
com.aliyuncs.exceptionsClientException<init>

Popular methods of ClientException

  • printStackTrace
  • getMessage
  • getErrCode
  • getErrMsg
  • getRequestId
  • setErrorType
  • toString

Popular in Java

  • Start an intent from android
  • requestLocationUpdates (LocationManager)
  • scheduleAtFixedRate (Timer)
  • getSystemService (Context)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • JButton (javax.swing)
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now