private static async Task EnsureSuccessStatusCode (HttpResponseMessage response)
{
if (!response.IsSuccessStatusCode)
{
string responseMessage = null;
try
{
using (var responseStream = await response.Content.ReadAsStreamAsync())
{
using (var reader = new StreamReader (responseStream, Encoding.UTF8))
{
responseMessage = reader.ReadToEnd();
}
}
}
catch (Exception x)
{
s_logger.Error ("Exception while trying to read the error message.", x);
}
throw new WebDavClientException (response.StatusCode, response.StatusCode.ToString(), responseMessage);
}
}