SkiaCodecException.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. public class SkiaCodecException : SkiaException
  10. {
  11. /// <summary>
  12. /// Initializes a new instance of the <see cref="SkiaCodecException" /> class.
  13. /// </summary>
  14. /// <param name="result">The non-successful codec result returned by Skia.</param>
  15. public SkiaCodecException(SKCodecResult result) : base()
  16. {
  17. CodecResult = result;
  18. }
  19. /// <summary>
  20. /// Initializes a new instance of the <see cref="SkiaCodecException" /> class
  21. /// with a specified error message.
  22. /// </summary>
  23. /// <param name="result">The non-successful codec result returned by Skia.</param>
  24. /// <param name="message">The message that describes the error.</param>
  25. public SkiaCodecException(SKCodecResult result, string message)
  26. : base(message)
  27. {
  28. CodecResult = result;
  29. }
  30. /// <summary>
  31. /// Gets the non-successful codec result returned by Skia.
  32. /// </summary>
  33. public SKCodecResult CodecResult { get; }
  34. /// <inheritdoc />
  35. public override string ToString()
  36. => string.Format(
  37. CultureInfo.InvariantCulture,
  38. "Non-success codec result: {0}\n{1}",
  39. CodecResult,
  40. base.ToString());
  41. }
  42. }