File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -148,7 +148,18 @@ private static unsafe void HandleError(int result)
148148 Func < string , GitErrorCategory , LibGit2SharpException > exceptionBuilder ;
149149 if ( ! GitErrorsToLibGit2SharpExceptions . TryGetValue ( ( GitErrorCode ) result , out exceptionBuilder ) )
150150 {
151- exceptionBuilder = ( m , c ) => new LibGit2SharpException ( m , c ) ;
151+ // The exception constructors in GitErrorsToLibGit2SharpExceptions make use of the error
152+ // category by passing it through to the NativeException(string message, GitErrorCategory category)
153+ // constructor which adds ("libgit2.category", category) to Data on System.Exception.
154+ //
155+ // We were calling new LibGit2SharpException(m, c) below, but this was resolving to the
156+ // string formatting constructor on LibGit2SharpException, because it does not have a constructor
157+ // that takes a category. This runs a string format, so if the errorMessage contained any curly
158+ // braces, that constructor would throw an System.FormatException.
159+ //
160+ // This has been changed to just use the message constructor (with no format arguments), and will drop
161+ // the error code (which is always Unknown anyway).
162+ exceptionBuilder = ( m , c ) => new LibGit2SharpException ( m ) ;
152163 }
153164
154165 throw exceptionBuilder ( errorMessage , errorCategory ) ;
You can’t perform that action at this time.
0 commit comments