Search in sources :

Example 26 with ClientException

use of com.aliyuncs.fc.exceptions.ClientException in project fc-java-sdk by aliyun.

the class ResponseFactory method genInvokeFunctionResponse.

public static InvokeFunctionResponse genInvokeFunctionResponse(HttpResponse response) throws ClientException, ServerException {
    InvokeFunctionResponse invokeFunctionResponse = new InvokeFunctionResponse();
    invokeFunctionResponse.setContent(response.getContent());
    invokeFunctionResponse.setPayload(response.getContent());
    invokeFunctionResponse.setHeaders(response.getHeaders());
    invokeFunctionResponse.setStatus(response.getStatus());
    Map<String, String> headers = response.getHeaders();
    if (headers != null && headers.containsKey(HeaderKeys.INVOCATION_LOG_RESULT)) {
        try {
            String logResult = Base64Helper.decode(headers.get(HeaderKeys.INVOCATION_LOG_RESULT), Const.DEFAULT_CHARSET);
            invokeFunctionResponse.setLogResult(logResult);
        } catch (IOException e) {
            throw new ClientException(e);
        }
    }
    return invokeFunctionResponse;
}
Also used : IOException(java.io.IOException) ClientException(com.aliyuncs.fc.exceptions.ClientException)

Aggregations

ClientException (com.aliyuncs.fc.exceptions.ClientException)26 Test (org.junit.Test)13 IOException (java.io.IOException)6 Gson (com.google.gson.Gson)5 ServerException (com.aliyuncs.fc.exceptions.ServerException)4 FunctionComputeClient (com.aliyuncs.fc.client.FunctionComputeClient)3 PrepareUrl (com.aliyuncs.fc.model.PrepareUrl)3 JsonParseException (com.google.gson.JsonParseException)3 SocketTimeoutException (java.net.SocketTimeoutException)3 InvalidKeyException (java.security.InvalidKeyException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 HttpResponse (com.aliyuncs.fc.http.HttpResponse)2 CreateServiceRequest (com.aliyuncs.fc.request.CreateServiceRequest)2 GetServiceRequest (com.aliyuncs.fc.request.GetServiceRequest)2 URISyntaxException (java.net.URISyntaxException)2 DefaultAcsClient (com.aliyuncs.DefaultAcsClient)1 IAcsClient (com.aliyuncs.IAcsClient)1 BasicSessionCredentials (com.aliyuncs.auth.BasicSessionCredentials)1 SignURLConfig (com.aliyuncs.fc.auth.SignURLConfig)1 Config (com.aliyuncs.fc.config.Config)1