Introduce base exception classes
GitReviewException: Handle also exceptions that are not related to the failed external commands at toplevel. ChangeSetException: For exceptions not related to the execution of the external command; such an exception is associated with a change set identifier. Change-Id: I8d165d1dfee5ec4e61487565e90b033fb6f58acf
This commit is contained in:
18
git-review
18
git-review
@@ -59,7 +59,11 @@ class colors:
|
|||||||
reset = '\033[0m'
|
reset = '\033[0m'
|
||||||
|
|
||||||
|
|
||||||
class CommandFailed(Exception):
|
class GitReviewException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class CommandFailed(GitReviewException):
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
Exception.__init__(self, *args)
|
Exception.__init__(self, *args)
|
||||||
@@ -78,6 +82,16 @@ The following command failed with exit code %(rc)d
|
|||||||
-----------------------""" % self.quickmsg
|
-----------------------""" % self.quickmsg
|
||||||
|
|
||||||
|
|
||||||
|
class ChangeSetException(GitReviewException):
|
||||||
|
|
||||||
|
def __init__(self, e):
|
||||||
|
GitReviewException.__init__(self)
|
||||||
|
self.e = str(e)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.__doc__ % self.e
|
||||||
|
|
||||||
|
|
||||||
def run_command_status(*argv, **env):
|
def run_command_status(*argv, **env):
|
||||||
if VERBOSE:
|
if VERBOSE:
|
||||||
print(datetime.datetime.now(), "Running:", " ".join(argv))
|
print(datetime.datetime.now(), "Running:", " ".join(argv))
|
||||||
@@ -861,6 +875,6 @@ def main():
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
main()
|
main()
|
||||||
except CommandFailed, e:
|
except GitReviewException, e:
|
||||||
print(e)
|
print(e)
|
||||||
sys.exit(e.EXIT_CODE)
|
sys.exit(e.EXIT_CODE)
|
||||||
|
|||||||
12
git-review.1
12
git-review.1
@@ -108,6 +108,18 @@ defaultremote=review
|
|||||||
defaultrebase=0
|
defaultrebase=0
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
|
.Sh DIAGNOSTICS
|
||||||
|
.Pp
|
||||||
|
Normally, exit status is 0 if executed successfully.
|
||||||
|
Exit status 1 indicates general error, sometimes more
|
||||||
|
specific error codes are available:
|
||||||
|
.Bl -tag -width 999
|
||||||
|
.It 2
|
||||||
|
Gerrit
|
||||||
|
.Ar commit-msg
|
||||||
|
hook could not be successfully installed.
|
||||||
|
.El
|
||||||
|
.Pp
|
||||||
.Sh EXAMPLES
|
.Sh EXAMPLES
|
||||||
To fetch a remote change number 3004:
|
To fetch a remote change number 3004:
|
||||||
.Pp
|
.Pp
|
||||||
|
|||||||
Reference in New Issue
Block a user