public void DryRun(AmazonEC2Client client, AmazonEC2Request request, ref DryRunResponse response)
{
response.IsSuccessful = false;
SetDryRun(request, true);
try
{
Method.Invoke(client, new object[] { request });
// If no exception thrown, consider this a failure
response.Message = "Unrecognized service response for the dry-run request.";
}
catch (Exception invokeException)
{
Exception actualException = invokeException.InnerException;
AmazonEC2Exception ec2e = actualException as AmazonEC2Exception;
response.Message = actualException.Message;
if (ec2e != null)
{
response.IsSuccessful = ec2e.StatusCode == HttpStatusCode.PreconditionFailed;
response.ResponseMetadata = new ResponseMetadata
{
RequestId = ec2e.RequestId
};
}
if (!response.IsSuccessful)
response.Error = actualException;
}
finally
{
SetDryRun(request, false);
}
}