sync: Share final error handling logic between sync modes
Bug: 421935613 Change-Id: I4604a83943dbbd71d979158d7a1c4b8c243347d2
This commit is contained in:
parent
37336085c4
commit
e87656f6e7
1 changed files with 40 additions and 21 deletions
|
@ -2127,13 +2127,31 @@ later is required to fix a server side protocol bug.
|
|||
|
||||
# If we saw an error, exit with code 1 so that other scripts can check.
|
||||
if err_event.is_set():
|
||||
self._ReportSyncErrors(
|
||||
errors,
|
||||
err_network=err_network_sync,
|
||||
err_checkout=err_checkout,
|
||||
err_update_projects=err_update_projects,
|
||||
err_update_linkfiles=err_update_linkfiles,
|
||||
failing_checkout_projects=err_results,
|
||||
)
|
||||
|
||||
def _ReportSyncErrors(
|
||||
self,
|
||||
errors: List[Exception],
|
||||
err_network: bool,
|
||||
err_checkout: bool,
|
||||
err_update_projects: bool,
|
||||
err_update_linkfiles: bool,
|
||||
failing_checkout_projects: List[str],
|
||||
):
|
||||
"""Common error reporting for sync failures."""
|
||||
def print_and_log(err_msg):
|
||||
self.git_event_log.ErrorEvent(err_msg)
|
||||
logger.error("%s", err_msg)
|
||||
|
||||
print_and_log("error: Unable to fully sync the tree")
|
||||
if err_network_sync:
|
||||
if err_network:
|
||||
print_and_log("error: Downloading network changes failed.")
|
||||
if err_update_projects:
|
||||
print_and_log("error: Updating local project lists failed.")
|
||||
|
@ -2141,13 +2159,14 @@ later is required to fix a server side protocol bug.
|
|||
print_and_log("error: Updating copyfiles or linkfiles failed.")
|
||||
if err_checkout:
|
||||
print_and_log("error: Checking out local projects failed.")
|
||||
if err_results:
|
||||
if failing_checkout_projects:
|
||||
# Don't log repositories, as it may contain sensitive info.
|
||||
logger.error("Failing repos:\n%s", "\n".join(err_results))
|
||||
logger.error(
|
||||
"Failing repos:\n%s", "\n".join(failing_checkout_projects)
|
||||
)
|
||||
# Not useful to log.
|
||||
logger.error(
|
||||
'Try re-running with "-j1 --fail-fast" to exit at the first '
|
||||
"error."
|
||||
'Try re-running with "-j1 --fail-fast" to exit at the first error.'
|
||||
)
|
||||
raise SyncError(aggregate_errors=errors)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue