Skip to content

Commit

Permalink
sort.py: print errors to stderr
Browse files Browse the repository at this point in the history
Misc: The trailing comma is due to using the opinionated `black` Python
formatter (which seems to be a relatively common one).  This was the
only change made, so the code seems to already be following the format
used by this tool.
  • Loading branch information
kmk3 committed Oct 18, 2022
1 parent 2be6e6f commit 81169ec
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions contrib/sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

# Requirements:
# python >= 3.6
from sys import argv, exit as sys_exit
from sys import argv, exit as sys_exit, stderr


def sort_alphabetical(original_items):
Expand Down Expand Up @@ -101,13 +101,16 @@ def main(args):
else:
fix_profile(filename)
except FileNotFoundError:
print(f"[ Error ] Can't find `{filename}'")
print(f"[ Error ] Can't find `{filename}'", file=stderr)
exit_code = 1
except PermissionError:
print(f"[ Error ] Can't read/write `{filename}'")
print(f"[ Error ] Can't read/write `{filename}'", file=stderr)
exit_code = 1
except Exception as err:
print(f"[ Error ] An error occurred while processing `{filename}': {err}")
print(
f"[ Error ] An error occurred while processing `{filename}': {err}",
file=stderr,
)
exit_code = 1
return exit_code

Expand Down

0 comments on commit 81169ec

Please sign in to comment.