SkiaCodecException.cs 1.5 KB

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