Csharp friendly errors #163

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants
Member

tclem commented Jun 1, 2012

This also introduces a new marshaler for GitError along with a distinction between exceptions (errors) in libgit2 vs. exceptions in libgit2sharp. It also makes the error names a bit more C# friendly:

GitErrorCode.NotFound vs. GitErrorCode.GIT_ENOTFOUND

I added a new exception type (see LibGit2SharpException and LibGit2Exception) so that you know whether an error is actually coming from libgit2 or if it is something LibGit2Sharp is checking. This should also make it easier to move towards LibGit2Sharp doing less work and deferring as much as we can to libgit2. I have tried to introduce this change in a way that does not break the public API.

tclem added some commits Jun 1, 2012

Use csharp friendly names for error classes/codes
This also introduces a new marshaler for GitError along with a distinction
between exception (errors) in libgit2 vs. exceptions in libgit2sharp.

See LibGit2SharpException and LibGit2Exception

This has been done in a way to not break the public API.
Remove BOM and cleanup .gitattributes
There is no need to call out Lib and other directories specifically in here
because we have .gitattributes files in those dirs.
Member

nulltoken commented Jun 3, 2012

Wow, that's a huge one ;)

I picked portions of it and pushed them toward vNext.

Below some thoughts about what haven't been merged yet:

  • I like very much the GitErrorMarshaler, however, I'm not sure it would handle messages containing Utf8 encoded parts. As some of those messages are built through printf() calls, it might safer
  • I prefer not to keep both LibGit2Exception and LibGit2SharpException types. The plan would be create explicit exceptions deriving from LibGit2SharpException (InvalidRepositoryException, DoNotMessWithTheHeadException, ...) /cc @half-ogre
Member

tclem commented Jun 4, 2012

I can take a look to see if the GitErrorMarshaler can be improved to deal with UTF8.

Member

tclem commented Jun 4, 2012

I like the idea of specific exceptions. I still think it is important to know if an exception is actually coming from libgit2 or whether it is being generated by the binding layer. This is an important distinction and a good benchmark for questioning whether the bindings are doing too much work or not.

Member

nulltoken commented Jun 4, 2012

I'm not sure to really understand the "what for" part ;)

This is an important distinction

Could you elaborate on this?

And a good benchmark for questioning whether the bindings are doing too much work or not.

How are you going to measure this?

Member

nulltoken commented Jun 4, 2012

I can take a look to see if the GitErrorMarshaler can be improved to deal with UTF8.

Thanks!

Member

tclem commented Jun 15, 2012

Ok, I reworked this a bit in #183

@tclem tclem closed this Jun 15, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment