private static string GenerateFailureMessage(HttpResult result, Exception inner)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (inner == null)
{
throw new ArgumentNullException("inner");
}
var lastOutcome = result.Outcomes.Last();
var outcomes = result.Outcomes.Aggregate(string.Empty, (x, y) => x + Environment.NewLine + y);
// We have been requested to go to a location that doesn't match the requested page
var message = string.Format(
CultureInfo.CurrentCulture,
"The {0} request to {1} has failed with the message '{2}'. The responses for this request were: {3}",
lastOutcome.Method,
lastOutcome.Location,
inner.Message,
outcomes);
return message;
}