mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-06-26 20:17:52 +00:00
Raise RepoExitError in place of sys.exit
Bug: b/293344017 Change-Id: Icae4932b00e4068cba502a5ab4a0274fd7854d9d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/382214 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Jason Chang <jasonnc@google.com> Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com> Commit-Queue: Jason Chang <jasonnc@google.com>
This commit is contained in:
23
main.py
23
main.py
@ -57,6 +57,7 @@ from error import RepoChangedException
|
||||
from error import RepoExitError
|
||||
from error import RepoUnhandledExceptionError
|
||||
from error import RepoError
|
||||
from error import SilentRepoExitError
|
||||
import gitc_utils
|
||||
from manifest_xml import GitcClient, RepoClient
|
||||
from pager import RunPager, TerminatePager
|
||||
@ -872,16 +873,20 @@ def _Main(argv):
|
||||
|
||||
result = repo._Run(name, gopts, argv) or 0
|
||||
except RepoExitError as e:
|
||||
exception_name = type(e).__name__
|
||||
if not isinstance(e, SilentRepoExitError):
|
||||
exception_name = type(e).__name__
|
||||
print("fatal: %s" % e, file=sys.stderr)
|
||||
if e.aggregate_errors:
|
||||
print(f"{exception_name} Aggregate Errors")
|
||||
for err in e.aggregate_errors[:MAX_PRINT_ERRORS]:
|
||||
print(err)
|
||||
if (
|
||||
e.aggregate_errors
|
||||
and len(e.aggregate_errors) > MAX_PRINT_ERRORS
|
||||
):
|
||||
diff = len(e.aggregate_errors) - MAX_PRINT_ERRORS
|
||||
print(f"+{diff} additional errors ...")
|
||||
result = e.exit_code
|
||||
print("fatal: %s" % e, file=sys.stderr)
|
||||
if e.aggregate_errors:
|
||||
print(f"{exception_name} Aggregate Errors")
|
||||
for err in e.aggregate_errors[:MAX_PRINT_ERRORS]:
|
||||
print(err)
|
||||
if len(e.aggregate_errors) > MAX_PRINT_ERRORS:
|
||||
diff = len(e.aggregate_errors) - MAX_PRINT_ERRORS
|
||||
print(f"+{diff} additional errors ...")
|
||||
except KeyboardInterrupt:
|
||||
print("aborted by user", file=sys.stderr)
|
||||
result = KEYBOARD_INTERRUPT_EXIT
|
||||
|
Reference in New Issue
Block a user