Improve exit code implementation

Unnecessary dynamic GitReviewException.EXIT_CODE attribute
lookup refactored into static to benefit static analyzers.

Default process exit code changed from 127 (command not found error)
to 1 (general error)

Change-Id: I1fcb583a740bf32c4427a587e208d099712a7bc4
This commit is contained in:
Ilya Etingof 2017-07-04 18:50:28 +02:00 committed by Sorin Sbarnea
parent af955c932e
commit d94e3a3431
2 changed files with 8 additions and 2 deletions

View File

@ -75,7 +75,7 @@ class colors(object):
class GitReviewException(Exception): class GitReviewException(Exception):
EXIT_CODE = 127 EXIT_CODE = 1
class CommandFailed(GitReviewException): class CommandFailed(GitReviewException):
@ -1704,7 +1704,7 @@ def main():
_main() _main()
except GitReviewException as e: except GitReviewException as e:
print(e) print(e)
sys.exit(getattr(e, 'EXIT_CODE', -1)) sys.exit(e.EXIT_CODE)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes ``gitreview`` process exit code to align with general
UNIX process exit code conventions. Specifically, default exit
code changed to ``1`` which stands for "general error".