aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Drawing.Skia/SkiaCodecException.cs
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2019-09-15 06:27:42 +0200
committerAnthony Lavado <anthony@lavado.ca>2019-09-15 00:27:42 -0400
commit318b9949f22d4ac061a14d1bf5aa4e8163ccec38 (patch)
treec5a7b956f578e861d1d7ff52fc6913ad6b66f8a5 /Jellyfin.Drawing.Skia/SkiaCodecException.cs
parentcc8609d0aace39b1c4198cee8fc9fc077d99a7b2 (diff)
Improve Skia error handling (#1752)
Diffstat (limited to 'Jellyfin.Drawing.Skia/SkiaCodecException.cs')
-rw-r--r--Jellyfin.Drawing.Skia/SkiaCodecException.cs46
1 files changed, 46 insertions, 0 deletions
diff --git a/Jellyfin.Drawing.Skia/SkiaCodecException.cs b/Jellyfin.Drawing.Skia/SkiaCodecException.cs
new file mode 100644
index 0000000000..f848636bcb
--- /dev/null
+++ b/Jellyfin.Drawing.Skia/SkiaCodecException.cs
@@ -0,0 +1,46 @@
+using System.Globalization;
+using SkiaSharp;
+
+namespace Jellyfin.Drawing.Skia
+{
+ /// <summary>
+ /// Represents errors that occur during interaction with Skia codecs.
+ /// </summary>
+ public class SkiaCodecException : SkiaException
+ {
+ /// <summary>
+ /// Returns the non-successfull codec result returned by Skia.
+ /// </summary>
+ /// <value>The non-successfull codec result returned by Skia.</value>
+ public SKCodecResult CodecResult { get; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SkiaCodecException" /> class.
+ /// </summary>
+ /// <param name="result">The non-successfull codec result returned by Skia.</param>
+ public SkiaCodecException(SKCodecResult result) : base()
+ {
+ CodecResult = result;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SkiaCodecException" /> class
+ /// with a specified error message.
+ /// </summary>
+ /// <param name="result">The non-successfull codec result returned by Skia.</param>
+ /// <param name="message">The message that describes the error.</param>
+ public SkiaCodecException(SKCodecResult result, string message)
+ : base(message)
+ {
+ CodecResult = result;
+ }
+
+ /// <inheritdoc />
+ public override string ToString()
+ => string.Format(
+ CultureInfo.InvariantCulture,
+ "Non-success codec result: {0}\n{1}",
+ CodecResult,
+ base.ToString());
+ }
+}