From f851460917db8ed47663e736bc741aa3bf1e82ca Mon Sep 17 00:00:00 2001 From: Sandro Hanea <40202887+sandrohanea@users.noreply.github.com> Date: Sun, 16 Feb 2025 17:03:52 +0100 Subject: [PATCH] Added pinvoke error to exception message (#348) Co-authored-by: Sandro Hanea --- Whisper.net/LibraryLoader/UniversalLibraryLoader.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Whisper.net/LibraryLoader/UniversalLibraryLoader.cs b/Whisper.net/LibraryLoader/UniversalLibraryLoader.cs index f846c0b1..40dd9a65 100644 --- a/Whisper.net/LibraryLoader/UniversalLibraryLoader.cs +++ b/Whisper.net/LibraryLoader/UniversalLibraryLoader.cs @@ -1,6 +1,7 @@ // Licensed under the MIT license: https://opensource.org/licenses/MIT #if !NETSTANDARD +using System.ComponentModel; using System.Reflection; using System.Runtime.InteropServices; @@ -21,7 +22,8 @@ public void CloseLibrary(nint handle) public string GetLastError() { - return "Cannot load the library on this platform using NativeLibrary"; + var pinvokeError = Marshal.GetLastPInvokeErrorMessage(); + return $"Cannot load the library on this platform using NativeLibrary. PInvokeError: {pinvokeError}"; } public bool TryOpenLibrary(string fileName, out IntPtr libHandle)