LitS3.S3Request.TryThrowS3Exception C# (CSharp) Method

TryThrowS3Exception() protected method

protected TryThrowS3Exception ( WebException exception ) : void
exception System.Net.WebException
return void
        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
            }
        }