diff options
author | 2022-10-18 03:54:17 -0300 | |
---|---|---|
committer | 2022-10-19 03:02:14 -0300 | |
commit | 9bf491212a8887e940ce9f272e107830e47dfc9d (patch) | |
tree | 1426f8743d7d5c0d873d8e884cc0d521eb388270 | |
parent | sort.py: print errors to stderr (diff) | |
download | firejail-9bf491212a8887e940ce9f272e107830e47dfc9d.tar.gz firejail-9bf491212a8887e940ce9f272e107830e47dfc9d.tar.zst firejail-9bf491212a8887e940ce9f272e107830e47dfc9d.zip |
sort.py: print more standard error messages
Where applicable, instead of creating custom ones.
Example error messages:
rm -f 123 && ./contrib/sort.py 123
[ Error ] [Errno 2] No such file or directory: '123'
touch 123 && chmod -rwx 123 && ./contrib/sort.py 123
[ Error ] [Errno 13] Permission denied: '123'
-rwxr-xr-x | contrib/sort.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/contrib/sort.py b/contrib/sort.py index 595ad0536..5cd4045f0 100755 --- a/contrib/sort.py +++ b/contrib/sort.py | |||
@@ -102,15 +102,15 @@ def main(args): | |||
102 | exit_code = fix_profile(filename) | 102 | exit_code = fix_profile(filename) |
103 | else: | 103 | else: |
104 | fix_profile(filename) | 104 | fix_profile(filename) |
105 | except FileNotFoundError: | 105 | except FileNotFoundError as err: |
106 | print(f"[ Error ] Can't find `{filename}'", file=stderr) | 106 | print(f"[ Error ] {err}", file=stderr) |
107 | exit_code = 1 | 107 | exit_code = 1 |
108 | except PermissionError: | 108 | except PermissionError as err: |
109 | print(f"[ Error ] Can't read/write `{filename}'", file=stderr) | 109 | print(f"[ Error ] {err}", file=stderr) |
110 | exit_code = 1 | 110 | exit_code = 1 |
111 | except Exception as err: | 111 | except Exception as err: |
112 | print( | 112 | print( |
113 | f"[ Error ] An error occurred while processing `{filename}': {err}", | 113 | f"[ Error ] An error occurred while processing '{filename}': {err}", |
114 | file=stderr, | 114 | file=stderr, |
115 | ) | 115 | ) |
116 | exit_code = 1 | 116 | exit_code = 1 |