Java Code Examples for com.aliyuncs.exceptions.ClientException#getMessage()

The following examples show how to use com.aliyuncs.exceptions.ClientException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SmsHelper.java    From tools with MIT License 6 votes vote down vote up
/**
 * Send SMS
 *
 * @param phones       Mobile phone number, multiple with English commas separated, the maximum of 1000
 * @param templateCode SMS template code
 * @param signName     SMS sign name
 * @param param        The actual value of the SMS template variable
 * @return Send the receipt
 */
public String send(String phones, String templateCode, String signName, Map<String, ?> param) {
    CommonRequest request = new CommonRequest();
    request.setMethod(MethodType.POST);
    request.setDomain(DO_MAIN);
    request.setVersion(VERSION);
    request.setAction("sendSms");
    request.putQueryParameter("PhoneNumbers", phones);
    if (param != null) {
        request.putQueryParameter("TemplateParam", new Gson().toJson(param));
    }
    request.putQueryParameter("TemplateCode", templateCode);
    request.putQueryParameter("SignName", signName);
    try {
        CommonResponse response = this.client.getCommonResponse(request);
        return response.getData();
    } catch (ClientException e) {
        throw new ToolsAliyunException(e.getMessage());
    }
}
 
Example 2
Source File: SmsHelper.java    From tools with MIT License 6 votes vote down vote up
/**
 * Query the record of sending the specified mobile phone number
 *
 * @param phone    Mobile phone number
 * @param sendDate Send date,Format for yyyy-MM-dd
 * @param page     Query page
 * @param row      No more than 50 pages per page
 * @return Query results
 */
public String findSendDetail(String phone, String sendDate, long page, long row) {
    if (row > 50) {
        throw new IllegalArgumentException("每页条数不能大于50");
    }
    CommonRequest request = new CommonRequest();
    request.setMethod(MethodType.POST);
    request.setDomain(DO_MAIN);
    request.setVersion(VERSION);
    request.setAction("QuerySendDetails");
    request.putQueryParameter("PhoneNumber", phone);
    request.putQueryParameter("SendDate", sendDate.replaceAll("-", ""));
    request.putQueryParameter("PageSize", String.valueOf(row));
    request.putQueryParameter("CurrentPage", String.valueOf(page));
    try {
        CommonResponse commonResponse = this.client.getCommonResponse(request);
        return commonResponse.getData();
    } catch (ClientException e) {
        throw new ToolsAliyunException(e.getMessage());
    }
}
 
Example 3
Source File: InstanceService.java    From cs-actions with Apache License 2.0 6 votes vote down vote up
private static AcsResponse getResponse(final String proxyHost,
                                       final String proxyPort,
                                       final String proxyUsername,
                                       final String proxyPassword,
                                       final IAcsClient client,
                                       final AcsRequest request) {


    try {
        if (!isEmpty(proxyHost)) {
            // Set JVM proxies during runtime
            ProxyUtil.setProxies(proxyHost, proxyPort, proxyUsername, proxyPassword);
            //Thread.sleep(30000);
        }
        return client.getAcsResponse(request);
    } catch (ClientException e) {
        throw new RuntimeException(e.getMessage());
    } finally {
        if (!isEmpty(proxyHost)) {
            //Clear proxies
            ProxyUtil.clearProxy();
        }
    }
}