Skip to content

Csharp friendly errors #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Conversation

tclem
Copy link
Member

@tclem 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 2 commits June 1, 2012 11:08
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.
There is no need to call out Lib and other directories specifically in here
because we have .gitattributes files in those dirs.
@nulltoken
Copy link
Member

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

@tclem
Copy link
Member Author

tclem commented Jun 4, 2012

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

@tclem
Copy link
Member Author

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.

@nulltoken
Copy link
Member

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?

@nulltoken
Copy link
Member

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

Thanks!

@tclem
Copy link
Member Author

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants