Skip to content

Commit

Permalink
sort.py: print more standard error messages
Browse files Browse the repository at this point in the history
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'
  • Loading branch information
kmk3 committed Oct 18, 2022
1 parent 81169ec commit afb2f52
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions contrib/sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ def main(args):
exit_code = fix_profile(filename)
else:
fix_profile(filename)
except FileNotFoundError:
print(f"[ Error ] Can't find `{filename}'", file=stderr)
except FileNotFoundError as err:
print(f"[ Error ] {err}", file=stderr)
exit_code = 1
except PermissionError:
print(f"[ Error ] Can't read/write `{filename}'", file=stderr)
except PermissionError as err:
print(f"[ Error ] {err}", file=stderr)
exit_code = 1
except Exception as err:
print(
f"[ Error ] An error occurred while processing `{filename}': {err}",
f"[ Error ] An error occurred while processing '{filename}': {err}",
file=stderr,
)
exit_code = 1
Expand Down

0 comments on commit afb2f52

Please sign in to comment.