SkiaCodecException.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System.Diagnostics.CodeAnalysis;
  2. using System.Globalization;
  3. using SkiaSharp;
  4. namespace Jellyfin.Drawing.Skia
  5. {
  6. /// <summary>
  7. /// Represents errors that occur during interaction with Skia codecs.
  8. /// </summary>
  9. [SuppressMessage("Design", "CA1032:Implement standard exception constructors", Justification = "A custom property, CodecResult, is required when creating this exception type.")]
  10. public class SkiaCodecException : SkiaException
  11. {
  12. /// <summary>
  13. /// Returns the non-successful codec result returned by Skia.
  14. /// </summary>
  15. /// <value>The non-successful codec result returned by Skia.</value>
  16. public SKCodecResult CodecResult { get; }
  17. /// <summary>
  18. /// Initializes a new instance of the <see cref="SkiaCodecException" /> class.
  19. /// </summary>
  20. /// <param name="result">The non-successful codec result returned by Skia.</param>
  21. public SkiaCodecException(SKCodecResult result) : base()
  22. {
  23. CodecResult = result;
  24. }
  25. /// <summary>
  26. /// Initializes a new instance of the <see cref="SkiaCodecException" /> class
  27. /// with a specified error message.
  28. /// </summary>
  29. /// <param name="result">The non-successful codec result returned by Skia.</param>
  30. /// <param name="message">The message that describes the error.</param>
  31. public SkiaCodecException(SKCodecResult result, string message)
  32. : base(message)
  33. {
  34. CodecResult = result;
  35. }
  36. /// <inheritdoc />
  37. public override string ToString()
  38. => string.Format(
  39. CultureInfo.InvariantCulture,
  40. "Non-success codec result: {0}\n{1}",
  41. CodecResult,
  42. base.ToString());
  43. }
  44. }