< Summary

Information
Class: System.Net.Http.HttpRequestException
Assembly: System.Net.Http
File(s): D:\runner\runtime\src\libraries\System.Net.Http\src\System\Net\Http\HttpRequestException.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 26
Coverable lines: 26
Total lines: 72
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor()100%110%
.ctor(...)100%110%
.ctor(...)0%220%
.ctor(...)100%110%
.ctor(...)100%110%
.ctor(...)100%110%

File(s)

D:\runner\runtime\src\libraries\System.Net.Http\src\System\Net\Http\HttpRequestException.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4namespace System.Net.Http
 5{
 6    public class HttpRequestException : Exception
 7    {
 08        internal RequestRetryType AllowRetry { get; } = RequestRetryType.NoRetry;
 9
 010        public HttpRequestException()
 011        { }
 12
 13        public HttpRequestException(string? message)
 014            : base(message)
 015        { }
 16
 17        public HttpRequestException(string? message, Exception? inner)
 018            : base(message, inner)
 019        {
 020            if (inner != null)
 021            {
 022                HResult = inner.HResult;
 023            }
 024        }
 25
 26        /// <summary>
 27        /// Initializes a new instance of the <see cref="HttpRequestException" /> class with a specific message that des
 28        /// </summary>
 29        /// <param name="message">A message that describes the current exception.</param>
 30        /// <param name="inner">The inner exception.</param>
 31        /// <param name="statusCode">The HTTP status code.</param>
 32        public HttpRequestException(string? message, Exception? inner, HttpStatusCode? statusCode)
 033            : this(message, inner)
 034        {
 035            StatusCode = statusCode;
 036        }
 37
 38        /// <summary>
 39        /// Initializes a new instance of the <see cref="HttpRequestException" /> class with a specific message an inner
 40        /// </summary>
 41        /// <param name="httpRequestError">The <see cref="HttpRequestError"/> that caused the exception.</param>
 42        /// <param name="message">A message that describes the current exception.</param>
 43        /// <param name="inner">The inner exception.</param>
 44        /// <param name="statusCode">The HTTP status code.</param>
 45        public HttpRequestException(HttpRequestError httpRequestError, string? message = null, Exception? inner = null, 
 046            : this(message, inner, statusCode)
 047        {
 048            HttpRequestError = httpRequestError;
 049        }
 50
 51        /// <summary>
 52        /// Gets the <see cref="Http.HttpRequestError"/> that caused the exception.
 53        /// </summary>
 054        public HttpRequestError HttpRequestError { get; }
 55
 56        /// <summary>
 57        /// Gets the HTTP status code to be returned with the exception.
 58        /// </summary>
 59        /// <value>
 60        /// An HTTP status code if the exception represents a non-successful result, otherwise <c>null</c>.
 61        /// </value>
 062        public HttpStatusCode? StatusCode { get; }
 63
 64        // This constructor is used internally to indicate that a request was not successfully sent due to an IOExceptio
 65        // and the exception occurred early enough so that the request may be retried on another connection.
 66        internal HttpRequestException(HttpRequestError httpRequestError, string? message, Exception? inner, RequestRetry
 067            : this(httpRequestError, message, inner)
 068        {
 069            AllowRetry = allowRetry;
 070        }
 71    }
 72}