Skip to content

Commit a17da7b

Browse files
committed
Improve errors
- the `--rooms` code/error message was potentially confusing - some errors weren't going to stderr
1 parent 5082839 commit a17da7b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

sogs/__main__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ def __call__(self, parser, ns, value, option_string=None):
192192
)
193193
sys.exit(1)
194194
if args.rooms and not update_room:
195-
print("Error: --rooms is not compatible with that option", file=sys.stderr)
195+
# If we have --rooms but didn't recognize any of the `update_rooms` options then that means
196+
# `--rooms` was specify with some action (e.g. `--initialize`) that doesn't support --rooms:
197+
print("Error: --rooms specified without a room modification option", file=sys.stderr)
196198
sys.exit(1)
197199

198200
from . import config, crypto, db
@@ -314,7 +316,7 @@ def perm_flag_to_word(char):
314316
if char == 'a':
315317
return "accessible"
316318

317-
print(f"Error: invalid permission flag '{char}'")
319+
print(f"Error: invalid permission flag '{char}'", file=sys.stderr)
318320
sys.exit(1)
319321

320322

@@ -327,7 +329,8 @@ def parse_and_set_perm_flags(flags, perm_setting):
327329
if perm_type in perms:
328330
print(
329331
f"Error: permission flag '{char}' in more than one permission set "
330-
"(add/remove/clear)"
332+
"(add/remove/clear)",
333+
file=sys.stderr,
331334
)
332335
sys.exit(1)
333336
perms[perm_type] = perm_setting
@@ -414,7 +417,7 @@ def parse_and_set_perm_flags(flags, perm_setting):
414417
sys.exit(1)
415418

416419
if not len(rooms) and not global_rooms:
417-
print("Error: --rooms is required when updating room settings/permissions")
420+
print("Error: --rooms is required when updating room settings/permissions", file=sys.stderr)
418421
sys.exit(1)
419422

420423
if args.add_moderators:

0 commit comments

Comments
 (0)