protected void TryThrowS3Exception(WebException exception)
{
// if this is a protocol error and the response type is XML, we can expect that
// S3 sent us an <Error> message.
if (exception.Status == WebExceptionStatus.ProtocolError &&
exception.Response.ContentType == "application/xml" &&
(exception.Response.ContentLength > 0 ||
exception.Response.Headers[HttpResponseHeader.TransferEncoding] == "chunked"))
{
var wrapped = S3Exception.FromWebException(exception);
if (wrapped != null)
throw wrapped; // do this on a separate statement so the debugger can re-execute
}
}