diff --git a/lib/aliyunsdkcore/roa_client.rb b/lib/aliyunsdkcore/roa_client.rb index 56555cb..5012601 100644 --- a/lib/aliyunsdkcore/roa_client.rb +++ b/lib/aliyunsdkcore/roa_client.rb @@ -48,8 +48,8 @@ def request(method:, uri:, params: {}, body: {}, headers: {}, options: {}) response_content_type = response.headers['Content-Type'] || '' if response_content_type.start_with?('application/json') if response.status >= 400 - result = JSON.parse(response.body) - raise StandardError, "code: #{response.status}, #{result['Message']} requestid: #{result['RequestId']}" + result = JSON.parse(response.body).transform_keys(&:downcase) + raise StandardError, "status: #{response.status}, code: #{result['code']}, message: #{result['message']}, requestid: #{result['requestid']}" end end diff --git a/spec/roa_client_spec.rb b/spec/roa_client_spec.rb index 2118e5c..3256428 100644 --- a/spec/roa_client_spec.rb +++ b/spec/roa_client_spec.rb @@ -147,7 +147,7 @@ .to_return(status: status, headers: headers, body: body) expect { roa_client.get(uri: '/', headers: { 'content-type': 'application/json' }) - }.to raise_error(StandardError, 'code: 400, error message requestid: requestid') + }.to raise_error(StandardError, 'status: 400, code: errorcode, message: error message, requestid: requestid') end end