Use DoNotWrapExceptions to avoid exception wrapping.

This commit is contained in:
Austin Wise
2019-12-05 19:29:35 -08:00
parent 1d0511aa21
commit 7f05a2e6a5

View File

@@ -240,7 +240,7 @@ namespace Wasmtime.Bindings
{ {
SetArgs(arguments, args); SetArgs(arguments, args);
var result = Method.Invoke(host, args); var result = Method.Invoke(host, BindingFlags.DoNotWrapExceptions, null, args, null);
if (hasReturn) if (hasReturn)
{ {
@@ -248,9 +248,9 @@ namespace Wasmtime.Bindings
} }
return IntPtr.Zero; return IntPtr.Zero;
} }
catch (TargetInvocationException ex) catch (Exception ex)
{ {
var bytes = Encoding.UTF8.GetBytes(ex.InnerException.Message + "\0" /* exception messages need a null */); var bytes = Encoding.UTF8.GetBytes(ex.Message + "\0" /* exception messages need a null */);
fixed (byte* ptr = bytes) fixed (byte* ptr = bytes)
{ {