@@ -130,25 +130,19 @@ private static readonly Dictionary<GitErrorCode, Func<string, GitErrorCode, GitE
130130{ GitErrorCode . Peel , ( m , r , c ) => new PeelException ( m , r , c ) } ,
131131} ;
132132
133- private static void HandleError ( int result )
133+ private static unsafe void HandleError ( int result )
134134{
135135string errorMessage ;
136- GitError error = null ;
137- var errHandle = NativeMethods . giterr_last ( ) ;
138-
139- if ( errHandle != null && ! errHandle . IsInvalid )
140- {
141- error = errHandle . MarshalAsGitError ( ) ;
142- }
136+ GitErrorCategory errorCategory = GitErrorCategory . Unknown ;
137+ GitError * error = NativeMethods . giterr_last ( ) ;
143138
144139if ( error == null )
145140{
146- error = new GitError { Category = GitErrorCategory . Unknown , Message = IntPtr . Zero } ;
147141errorMessage = "No error message has been provided by the native library" ;
148142}
149143else
150144{
151- errorMessage = LaxUtf8Marshaler . FromNative ( error . Message ) ;
145+ errorMessage = LaxUtf8Marshaler . FromNative ( error -> Message ) ;
152146}
153147
154148Func < string , GitErrorCode , GitErrorCategory , LibGit2SharpException > exceptionBuilder ;
@@ -157,7 +151,7 @@ private static void HandleError(int result)
157151exceptionBuilder = ( m , r , c ) => new LibGit2SharpException ( m , r , c ) ;
158152}
159153
160- throw exceptionBuilder ( errorMessage , ( GitErrorCode ) result , error . Category ) ;
154+ throw exceptionBuilder ( errorMessage , ( GitErrorCode ) result , errorCategory ) ;
161155}
162156
163157/// <summary>
0 commit comments