libgit2 / libgit2sharp

Git + .NET = ❤
http://libgit2.github.com
MIT License
3.18k stars 887 forks source link

Most exceptions have the same type of LibGit2SharpException #1934

Open thealifaisal opened 2 years ago

thealifaisal commented 2 years ago

Most exceptions have the same type of LibGit2SharpException, which makes it difficult to filter specific exceptions and throw our own exception with some custom message. One example is below:

Reproduction steps

When we provide incorrect credentials, it gives an error message "Too many authentication replays" with an exception type of LibGit2SharpException. Because of this, we cannot identify exception based on its type and provide a more user friendly exception.

Version of LibGit2Sharp (release number or SHA1)

0.27.0-preview-0158

Operating system(s) tested; .NET runtime tested

OS: Windows 10 .NET runtime: .NET 6.0

ethomson commented 2 years ago

In this particular example, you should return an error from your credential handler. You're seeing the "last chance" error message when libgit2 had prevented infinite loops of credential failures.