diff options
Diffstat (limited to 'Ryujinx.Graphics.Vulkan/VulkanException.cs')
-rw-r--r-- | Ryujinx.Graphics.Vulkan/VulkanException.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Vulkan/VulkanException.cs b/Ryujinx.Graphics.Vulkan/VulkanException.cs new file mode 100644 index 00000000..983f03d4 --- /dev/null +++ b/Ryujinx.Graphics.Vulkan/VulkanException.cs @@ -0,0 +1,41 @@ +using Silk.NET.Vulkan; +using System; +using System.Runtime.Serialization; + +namespace Ryujinx.Graphics.Vulkan +{ + static class ResultExtensions + { + public static void ThrowOnError(this Result result) + { + // Only negative result codes are errors. + if ((int)result < (int)Result.Success) + { + throw new VulkanException(result); + } + } + } + + class VulkanException : Exception + { + public VulkanException() + { + } + + public VulkanException(Result result) : base($"Unexpected API error \"{result}\".") + { + } + + public VulkanException(string message) : base(message) + { + } + + public VulkanException(string message, Exception innerException) : base(message, innerException) + { + } + + protected VulkanException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } + } +} |