diff options
author | cos <cos> | 2024-07-03 01:11:57 +0200 |
---|---|---|
committer | cos <cos> | 2024-07-03 11:31:23 +0200 |
commit | 51e0b338fc72a28b7e50c8ded9eeddb049f8b773 (patch) | |
tree | 629424ceda886ca83573cdf127c8f84ebd2986e4 | |
parent | b3a60de68ffef2846181f0dd84e80488a06632fe (diff) | |
download | AntennaPodDbFixer-51e0b338fc72a28b7e50c8ded9eeddb049f8b773.zip |
Improve error handling slightly
Use non-zero return codes for failed execution and output errors to
stderr.
-rwxr-xr-x | AntennaPodDbFixer.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/AntennaPodDbFixer.py b/AntennaPodDbFixer.py index e5a9835..15d225a 100755 --- a/AntennaPodDbFixer.py +++ b/AntennaPodDbFixer.py @@ -34,8 +34,8 @@ corruptedVersion = subprocess.run( text=True ).stdout.strip() if corruptedVersion == "0": - print("Error: File not found, not a database, or too corrupted for this script.") - exit() + print("Error: File not found, not a database, or too corrupted for this script.", file=sys.stderr) + exit(1) print("Corrupted file version: " + corruptedVersion) emptyFilePath = "empty/" + corruptedVersion + ".db" @@ -49,8 +49,8 @@ if not os.path.isfile(emptyFilePath): ).stdout.strip() print("Empty file version: " + emptyVersion) if corruptedVersion != emptyVersion: - print("Error: Version does not match") - exit() + print("Error: Application version differs between database files.", file=sys.stderr) + exit(1) print() repairedFilePath = inputFilePath + "-repaired.db" @@ -93,7 +93,7 @@ def query(db, query): return json.loads(result) except subprocess.CalledProcessError as err: print(err.stderr) - exit() + exit(1) except json.decoder.JSONDecodeError as err: return result |