aboutsummaryrefslogtreecommitdiff
path: root/git/exc.py
diff options
context:
space:
mode:
Diffstat (limited to 'git/exc.py')
-rw-r--r--git/exc.py49
1 files changed, 43 insertions, 6 deletions
diff --git a/git/exc.py b/git/exc.py
index d2cb8d7e..e14fb7f1 100644
--- a/git/exc.py
+++ b/git/exc.py
@@ -5,17 +5,53 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
""" Module containing all exceptions thrown througout the git package, """
-from gitdb.exc import *
+from util import to_hex_sha
-class InvalidGitRepositoryError(Exception):
+class GitPythonError(Exception):
+ """Base exception for all git-python related errors"""
+
+class ODBError(GitPythonError):
+ """All errors thrown by the object database"""
+
+
+class InvalidDBRoot(ODBError):
+ """Thrown if an object database cannot be initialized at the given path"""
+
+
+class BadObject(ODBError):
+ """The object with the given SHA does not exist. Instantiate with the
+ failed sha"""
+
+ def __str__(self):
+ return "BadObject: %s" % to_hex_sha(self.args[0])
+
+
+class ParseError(ODBError):
+ """Thrown if the parsing of a file failed due to an invalid format"""
+
+
+class AmbiguousObjectName(ODBError):
+ """Thrown if a possibly shortened name does not uniquely represent a single object
+ in the database"""
+
+
+class BadObjectType(ODBError):
+ """The object had an unsupported type"""
+
+
+class UnsupportedOperation(ODBError):
+ """Thrown if the given operation cannot be supported by the object database"""
+
+
+class InvalidGitRepositoryError(InvalidDBRoot):
""" Thrown if the given repository appears to have an invalid format. """
-class NoSuchPathError(OSError):
+class NoSuchPathError(InvalidDBRoot):
""" Thrown if a path could not be access by the system. """
-class GitCommandError(Exception):
+class GitCommandError(GitPythonError):
""" Thrown if execution of the git command fails with non-zero status code. """
def __init__(self, command, status, stderr=None):
self.stderr = stderr
@@ -27,7 +63,7 @@ class GitCommandError(Exception):
(' '.join(str(i) for i in self.command), self.status, self.stderr))
-class CheckoutError( Exception ):
+class CheckoutError(GitPythonError):
"""Thrown if a file could not be checked out from the index as it contained
changes.
@@ -50,9 +86,10 @@ class CheckoutError( Exception ):
return Exception.__str__(self) + ":%s" % self.failed_files
-class CacheError(Exception):
+class CacheError(GitPythonError):
"""Base for all errors related to the git index, which is called cache internally"""
+
class UnmergedEntriesError(CacheError):
"""Thrown if an operation cannot proceed as there are still unmerged
entries in the cache"""