Avoid AttributeError when raising raw GitReviewExceptions

Previously, if a GitReviewException was raised (not, for example, a
BranchTrackingMismatch or GitDirectoriesException which subclasses it,
but an actual GitReviewException), it would still get handled in main(),
but it wouldn't have an EXIT_CODE attribute.

This happens, for example, in add_remote(), if test_remote_url() fails
both times.

Now, if the caught exception doesn't have an EXIT_CODE, it will default
to -1.

Change-Id: I8529b320795717ef8d19ca87d3fa6bd523ef93ae
This commit is contained in:
Tim Burke 2015-10-28 18:04:38 -07:00
parent cfb726e4a0
commit 26e2f72b26

View File

@ -1570,7 +1570,7 @@ def main():
print(e)
else:
print(u.encode('utf-8'))
sys.exit(e.EXIT_CODE)
sys.exit(getattr(e, 'EXIT_CODE', -1))
if __name__ == "__main__":