mirror of
https://github.com/LukeHagar/plexcsharp.git
synced 2025-12-06 12:37:46 +00:00
81 lines
2.3 KiB
C#
81 lines
2.3 KiB
C#
//------------------------------------------------------------------------------
|
|
// <auto-generated>
|
|
// This code was generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
//
|
|
// Changes to this file may cause incorrect behavior and will be lost when
|
|
// the code is regenerated.
|
|
// </auto-generated>
|
|
//------------------------------------------------------------------------------
|
|
|
|
#nullable enable
|
|
namespace LukeHagar.PlexAPI.SDK.Models.Errors
|
|
{
|
|
using System;
|
|
using System.Net.Http;
|
|
using System.Net.Http.Headers;
|
|
|
|
public class PlexAPIError : Exception
|
|
{
|
|
/// <summary>
|
|
/// Error Message
|
|
/// </summary>
|
|
public override string Message { get; }
|
|
|
|
/// <summary>
|
|
/// HTTP status code
|
|
/// </summary>
|
|
public int StatusCode { get; }
|
|
|
|
/// <summary>
|
|
/// HTTP headers
|
|
/// </summary>
|
|
public HttpResponseHeaders Headers { get; }
|
|
|
|
/// <summary>
|
|
/// HTTP content type
|
|
/// </summary>
|
|
public string? ContentType { get; }
|
|
|
|
/// <summary>
|
|
/// Raw response
|
|
/// </summary>
|
|
public HttpResponseMessage RawResponse { get; }
|
|
|
|
/// <summary>
|
|
/// HTTP response body
|
|
/// </summary>
|
|
public string Body { get; }
|
|
|
|
public PlexAPIError(
|
|
string message,
|
|
HttpResponseMessage rawResponse,
|
|
string body
|
|
) : this(message, rawResponse, body, null) {}
|
|
|
|
public PlexAPIError(
|
|
string message,
|
|
HttpResponseMessage rawResponse,
|
|
string body,
|
|
Exception? innerException
|
|
) : base(message, innerException)
|
|
{
|
|
Message = message;
|
|
RawResponse = rawResponse;
|
|
StatusCode = (int)rawResponse.StatusCode;
|
|
Headers = rawResponse.Headers;
|
|
ContentType = rawResponse.Content.Headers.ContentType?.MediaType;
|
|
Body = body;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Detailed Error Message
|
|
/// </summary>
|
|
public override string ToString()
|
|
{
|
|
var innerMessage = string.IsNullOrEmpty(InnerException?.Message) ? "" : $"\n{InnerException.Message}";
|
|
return $"Status: {StatusCode}. {Message}{innerMessage}";
|
|
}
|
|
|
|
}
|
|
}
|