99from git .compat import UnicodeMixin , safe_decode , string_types
1010
1111
12- class InvalidGitRepositoryError (Exception ):
12+ class GitError (Exception ):
13+ """ Base class for all package exceptions """
14+
15+
16+ class InvalidGitRepositoryError (GitError ):
1317 """ Thrown if the given repository appears to have an invalid format. """
1418
1519
1620class WorkTreeRepositoryUnsupported (InvalidGitRepositoryError ):
1721 """ Thrown to indicate we can't handle work tree repositories """
1822
1923
20- class NoSuchPathError (OSError ):
24+ class NoSuchPathError (GitError , OSError ):
2125 """ Thrown if a path could not be access by the system. """
2226
2327
24- class CommandError (UnicodeMixin , Exception ):
28+ class CommandError (UnicodeMixin , GitError ):
2529 """Base class for exceptions thrown at every stage of `Popen()` execution.
2630
2731 :param command:
@@ -74,7 +78,7 @@ def __init__(self, command, status, stderr=None, stdout=None):
7478 super (GitCommandError , self ).__init__ (command , status , stderr , stdout )
7579
7680
77- class CheckoutError (Exception ):
81+ class CheckoutError (GitError ):
7882 """Thrown if a file could not be checked out from the index as it contained
7983 changes.
8084
@@ -98,7 +102,7 @@ def __str__(self):
98102 return Exception .__str__ (self ) + ":%s" % self .failed_files
99103
100104
101- class CacheError (Exception ):
105+ class CacheError (GitError ):
102106
103107 """Base for all errors related to the git index, which is called cache internally"""
104108
@@ -117,7 +121,7 @@ def __init__(self, command, status, stderr=None, stdout=None):
117121 self ._msg = u"Hook('%s') failed%s"
118122
119123
120- class RepositoryDirtyError (Exception ):
124+ class RepositoryDirtyError (GitError ):
121125 """Thrown whenever an operation on a repository fails as it has uncommitted changes that would be overwritten"""
122126
123127 def __init__ (self , repo , message ):
0 commit comments