SkiaCodecException.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Globalization;
  2. using SkiaSharp;
  3. namespace Jellyfin.Drawing.Skia
  4. {
  5. /// <summary>
  6. /// Represents errors that occur during interaction with Skia codecs.
  7. /// </summary>
  8. public class SkiaCodecException : SkiaException
  9. {
  10. /// <summary>
  11. /// Returns the non-successfull codec result returned by Skia.
  12. /// </summary>
  13. /// <value>The non-successfull codec result returned by Skia.</value>
  14. public SKCodecResult CodecResult { get; }
  15. /// <summary>
  16. /// Initializes a new instance of the <see cref="SkiaCodecException" /> class.
  17. /// </summary>
  18. /// <param name="result">The non-successfull codec result returned by Skia.</param>
  19. public SkiaCodecException(SKCodecResult result) : base()
  20. {
  21. CodecResult = result;
  22. }
  23. /// <summary>
  24. /// Initializes a new instance of the <see cref="SkiaCodecException" /> class
  25. /// with a specified error message.
  26. /// </summary>
  27. /// <param name="result">The non-successfull codec result returned by Skia.</param>
  28. /// <param name="message">The message that describes the error.</param>
  29. public SkiaCodecException(SKCodecResult result, string message)
  30. : base(message)
  31. {
  32. CodecResult = result;
  33. }
  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. }