aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Net/HttpResponseBodyException.cs
blob: 2194640b6193f843c269ec3187e6560e47d1c4c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System.Net;
using System.Net.Http;

namespace MediaBrowser.Common.Net;

/// <summary>
/// An <see cref="HttpRequestException"/> that retains the body of the failed response.
/// </summary>
/// <remarks>
/// Providers report why they refused a request in the response body, which
/// <see cref="HttpResponseMessage.EnsureSuccessStatusCode"/> discards.
/// </remarks>
public class HttpResponseBodyException : HttpRequestException
{
    /// <summary>
    /// Initializes a new instance of the <see cref="HttpResponseBodyException"/> class.
    /// </summary>
    /// <param name="message">The exception message.</param>
    /// <param name="statusCode">The status code of the failed response.</param>
    /// <param name="responseBody">The body of the failed response.</param>
    public HttpResponseBodyException(string message, HttpStatusCode? statusCode, string? responseBody)
        : base(message, null, statusCode)
    {
        ResponseBody = responseBody;
    }

    /// <summary>
    /// Gets the body of the failed response.
    /// </summary>
    public string? ResponseBody { get; }
}