diff --git a/build/mach_bootstrap.py b/build/mach_bootstrap.py index 9ee21bac5f441..799fc872c9d2a 100644 --- a/build/mach_bootstrap.py +++ b/build/mach_bootstrap.py @@ -169,11 +169,8 @@ def resolve_repository(): # If we ever need to use the VCS binary here, consider something # more robust. return mozversioncontrol.get_repository_object(path=mozilla_dir) - except mozversioncontrol.InvalidRepoPath: - return None - # This is mainly to catch failures resolving the VCS binary path. - # TODO Change mozversioncontrol to raise non-generic exception. - except Exception: + except (mozversioncontrol.InvalidRepoPath, + mozversioncontrol.MissingVCSTool): return None def telemetry_handler(context, data): diff --git a/python/mozversioncontrol/mozversioncontrol/__init__.py b/python/mozversioncontrol/mozversioncontrol/__init__.py index e0ded5d2d7255..2773014e3bb84 100644 --- a/python/mozversioncontrol/mozversioncontrol/__init__.py +++ b/python/mozversioncontrol/mozversioncontrol/__init__.py @@ -14,6 +14,10 @@ from distutils.version import LooseVersion +class MissingVCSTool(Exception): + """Represents a failure to find a version control tool binary.""" + + def get_tool_path(tool): """Obtain the path of `tool`.""" if os.path.isabs(tool) and os.path.exists(tool): @@ -30,11 +34,11 @@ def get_tool_path(tool): try: return which.which(tool) except which.WhichError as e: - print(e) + pass - raise Exception('Unable to obtain %s path. Try running ' - '|mach bootstrap| to ensure your environment is up to ' - 'date.' % tool) + raise MissingVCSTool('Unable to obtain %s path. Try running ' + '|mach bootstrap| to ensure your environment is up to ' + 'date.' % tool) class Repository(object):