| |
@@ -299,6 +299,22 @@
|
| |
autochangelog_re = r"^\s*%(?:autochangelog|\{\??autochangelog\})\b"
|
| |
return any(re.match(autochangelog_re, line) for line in text.splitlines())
|
| |
|
| |
+
|
| |
+ @contextlib.contextmanager
|
| |
+ def exit_on_common_errors():
|
| |
+ """Suppress tracebacks on common "expected" exceptions"""
|
| |
+ try:
|
| |
+ yield
|
| |
+ except requests.exceptions.HTTPError as e:
|
| |
+ sys.exit(f'Failed to download metadata: {e}')
|
| |
+ except subprocess.CalledProcessError as e:
|
| |
+ cmd = shlex.join(e.cmd)
|
| |
+ sys.exit(f'Subcommand failed with code {e.returncode}: {cmd}')
|
| |
+ except FileNotFoundError as e:
|
| |
+ sys.exit(str(e))
|
| |
+
|
| |
+
|
| |
+ @exit_on_common_errors()
|
| |
def main():
|
| |
default_target = get_default_target()
|
| |
|
| |
@@ -473,11 +489,6 @@
|
| |
with open(patch_file, "w") as fobj:
|
| |
fobj.writelines(diff)
|
| |
|
| |
+
|
| |
if __name__ == "__main__":
|
| |
- try:
|
| |
- main()
|
| |
- except requests.exceptions.HTTPError as e:
|
| |
- sys.exit(f'Failed to download metadata: {e}')
|
| |
- except subprocess.CalledProcessError as e:
|
| |
- cmd = shlex.join(e.cmd)
|
| |
- sys.exit(f'Subcommand failed with code {e.returncode}: {cmd}')
|
| |
+ main()
|
| |