libgit2 / pygit2

Python bindings for libgit2
https://www.pygit2.org/
Other
1.62k stars 392 forks source link

Review exceptions #830

Open jdavid opened 6 years ago

jdavid commented 6 years ago

To have one exception for every GIT_EXXX all of them inheriting from GitError, use a consistent naming, e.g. GIT_EINVALIDSPEC would become GitInvalidSpecError or maybe just InvalidSpecError.

To provide backwards compatibility use multiple inheritance, e.g. InvalidSpecError would inherit from GitError and ValueError. Eventually the base class for backwards compatibility would be remove in some future version.

To settle on naming post here the full mapping of GIT_EXXX to exception, even if this can be implemented in steps.

This follows up on issues #531 and #828

robinst commented 6 years ago

Sounds good to me.

Eventually the base class for backwards compatibility would be remove in some future version.

There's some precedent in Python's standard library for exceptions with multiple base classes, see this post:

https://www.reddit.com/r/Python/comments/1k9ygb/multiple_inheritance_for_library_exceptions/

So maybe it's not necessarily a bad thing that needs to be removed in the future.

jdavid commented 6 years ago

yes you're right, it may be a good thing

omniproc commented 4 years ago

While I implemented a first version there are currently some reasons that stop us from fully switching to such a system that will probably need to be tackled one-by-one.