aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Net/HttpResponseBodyException.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Common/Net/HttpResponseBodyException.cs')
-rw-r--r--MediaBrowser.Common/Net/HttpResponseBodyException.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/MediaBrowser.Common/Net/HttpResponseBodyException.cs b/MediaBrowser.Common/Net/HttpResponseBodyException.cs
new file mode 100644
index 0000000000..2194640b61
--- /dev/null
+++ b/MediaBrowser.Common/Net/HttpResponseBodyException.cs
@@ -0,0 +1,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; }
+}