Skip to content

Commit

Permalink
Report invalid effective listen_on as a bad config error
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Oct 29, 2023
1 parent 24d9d50 commit 778adfc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 8 additions & 5 deletions kitty/boss.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ def __init__(
self.os_window_death_actions: Dict[int, Callable[[], None]] = {}
self.cursor_blinking = True
self.shutting_down = False
self.misc_config_errors: List[str] = []
talk_fd = getattr(single_instance, 'socket', None)
talk_fd = -1 if talk_fd is None else talk_fd.fileno()
listen_fd = -1
Expand All @@ -367,9 +368,8 @@ def __init__(
try:
listen_fd, self.listening_on = listen_on(args.listen_on)
except Exception:
log_error(f'Invalid listen_on setting: {args.listen_on}, ignoring')
import traceback
traceback.print_exc()
self.misc_config_errors.append(f'Invalid listen_on={args.listen_on}, ignoring')
log_error(self.misc_config_errors[-1])
self.child_monitor = ChildMonitor(
self.on_child_death,
DumpCommands(args) if args.dump_commands or args.dump_bytes else None,
Expand Down Expand Up @@ -2633,7 +2633,7 @@ def dbus_notification_callback(self, activated: bool, a: int, b: Union[int, str]
assert isinstance(b, int)
dbus_notification_created(a, b)

def show_bad_config_lines(self, bad_lines: Iterable[BadLine]) -> None:
def show_bad_config_lines(self, bad_lines: Iterable[BadLine], misc_errors: Iterable[str] = ()) -> None:

def format_bad_line(bad_line: BadLine) -> str:
return f'{bad_line.number}:{bad_line.exception} in line: {bad_line.line}\n'
Expand All @@ -2647,7 +2647,10 @@ def format_bad_line(bad_line: BadLine) -> str:
if file:
a(f'In file {file}:')
[a(format_bad_line(x)) for x in groups[file]]

if misc_errors:
a('In final effective configuration:')
for line in misc_errors:
a(line)
msg = '\n'.join(ans).rstrip()
self.show_error(_('Errors parsing configuration'), msg)

Expand Down
5 changes: 3 additions & 2 deletions kitty/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,9 @@ def _run_app(opts: Options, args: CLIOptions, bad_lines: Sequence[BadLine] = ())
wincls, wstate, load_all_shaders, disallow_override_title=bool(args.title))
boss = Boss(opts, args, cached_values, global_shortcuts)
boss.start(window_id, startup_sessions)
if bad_lines:
boss.show_bad_config_lines(bad_lines)
if bad_lines or boss.misc_config_errors:
boss.show_bad_config_lines(bad_lines, boss.misc_config_errors)
boss.misc_config_errors = []
try:
boss.child_monitor.main_loop()
finally:
Expand Down

0 comments on commit 778adfc

Please sign in to comment.