using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using SkiaSharp;
namespace Jellyfin.Drawing.Skia
{
///
/// Represents errors that occur during interaction with Skia codecs.
///
[SuppressMessage("Design", "CA1032:Implement standard exception constructors", Justification = "A custom property, CodecResult, is required when creating this exception type.")]
public class SkiaCodecException : SkiaException
{
///
/// Returns the non-successful codec result returned by Skia.
///
/// The non-successful codec result returned by Skia.
public SKCodecResult CodecResult { get; }
///
/// Initializes a new instance of the class.
///
/// The non-successful codec result returned by Skia.
public SkiaCodecException(SKCodecResult result) : base()
{
CodecResult = result;
}
///
/// Initializes a new instance of the class
/// with a specified error message.
///
/// The non-successful codec result returned by Skia.
/// The message that describes the error.
public SkiaCodecException(SKCodecResult result, string message)
: base(message)
{
CodecResult = result;
}
///
public override string ToString()
=> string.Format(
CultureInfo.InvariantCulture,
"Non-success codec result: {0}\n{1}",
CodecResult,
base.ToString());
}
}