public T handleResponse()

in src/main/java/com/alibaba/yjopenapi/client/api/ApiClient.java [498:522]


    public <T> T handleResponse(Response response, Class<T> returnType) throws ApiException {
        if (response.isSuccessful()) {
            if (returnType == null) {
                // returning null if the returnType is not defined,
                // or the status code is 204 (No Content)
                try (ResponseBody body = response.body()) {
                    return null;
                } catch (IOException e) {
                    throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap());
                }
            } else {
                return deserialize(response, returnType);
            }
        } else {
            try (ResponseBody body = response.body()) {
                String respBody = null;
                if (body != null) {
                    respBody = body.string();
                }
                throw new ApiException(response.message(), response.code(), response.headers().toMultimap(), respBody);
            } catch (IOException e) {
                throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap());
            }
        }
    }