Skip to content

Commit

Permalink
Added pinvoke error to exception message (sandrohanea#348)
Browse files Browse the repository at this point in the history
Co-authored-by: Sandro Hanea <sandro@echosharp.net>
  • Loading branch information
sandrohanea and Sandro Hanea authored Feb 16, 2025
1 parent 8571160 commit f851460
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Whisper.net/LibraryLoader/UniversalLibraryLoader.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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)
Expand Down

0 comments on commit f851460

Please # to comment.