Skip to content

Commit e39a21d

Browse files
committed
Add type details to FilePathMarshaler error
1 parent c000936 commit e39a21d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

LibGit2Sharp/Core/FilePathMarshaler.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Globalization;
23
using System.Runtime.InteropServices;
34

45
namespace LibGit2Sharp.Core
@@ -83,7 +84,14 @@ public IntPtr MarshalManagedToNative(Object managedObj)
8384

8485
if (null == filePath)
8586
{
86-
throw new MarshalDirectiveException("FilePathMarshaler must be used on a FilePath.");
87+
var expectedType = typeof(FilePath);
88+
var actualType = managedObj.GetType();
89+
90+
throw new MarshalDirectiveException(
91+
string.Format(CultureInfo.InvariantCulture,
92+
"FilePathMarshaler must be used on a FilePath. Expected '{0}' from '{1}'; received '{2}' from '{3}'.",
93+
expectedType.FullName, expectedType.Assembly.Location,
94+
actualType.FullName, actualType.Assembly.Location));
8795
}
8896

8997
return FromManaged(filePath);

0 commit comments

Comments
 (0)