Use an accurate title for the overlay showing startup errors

Errors during startup that are not caused by invalid config lines, such
as failing to listen on the remote control socket, were shown under the
title "Errors parsing configuration" with the heading "In final effective
configuration". The title now reflects whether the errors are config
parse errors, startup errors or both.
This commit is contained in:
Kovid Goyal 2026-11-07 11:03:56 +05:30
parent df1fda1032
commit c0a5e2cf37
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 30 additions and 5 deletions

View file

@ -3906,12 +3906,22 @@ class Boss:
if file:
a(f'In file {file}:')
[a(format_bad_line(x)) for x in groups[file]]
# misc_errors are errors that happen during startup that are not
# caused by invalid lines in the config, such as failing to listen on
# the remote control socket
if misc_errors := tuple(misc_errors):
a('In final effective configuration:')
if groups:
a('Other errors:')
for line in misc_errors:
a(line)
msg = '\n'.join(ans).rstrip()
self.show_error(_('Errors parsing configuration'), msg)
if groups and misc_errors:
title = _('Errors parsing configuration and during startup')
elif misc_errors:
title = _('Errors during startup')
else:
title = _('Errors parsing configuration')
self.show_error(title, msg)
@ac(
'misc',

View file

@ -48,12 +48,27 @@ class IterableArgumentsTest(BaseTest):
def test_config_error_iterable(self):
for container in (list, tuple, iter):
for values in ((), ('configuration error',)):
for values in ((), ('startup error',)):
with self.subTest(container=container, values=values):
boss = SimpleNamespace(show_error=Mock())
Boss.show_bad_config_lines(boss, (), container(values))
message = boss.show_error.call_args.args[1]
self.ae(message, 'In final effective configuration:\nconfiguration error' if values else '')
title, message = boss.show_error.call_args.args[:2]
self.ae(message, 'startup error' if values else '')
self.ae(title, 'Errors during startup' if values else 'Errors parsing configuration')
def test_config_error_titles(self):
from kitty.conf.utils import BadLine
bad = BadLine(3, 'font_size x', ValueError('invalid'), '/some/kitty.conf')
boss = SimpleNamespace(show_error=Mock())
Boss.show_bad_config_lines(boss, (bad,))
title, message = boss.show_error.call_args.args[:2]
self.ae(title, 'Errors parsing configuration')
self.ae(message, 'In file /some/kitty.conf:\n3:invalid in line: font_size x')
Boss.show_bad_config_lines(boss, (bad,), ('startup error',))
title, message = boss.show_error.call_args.args[:2]
self.ae(title, 'Errors parsing configuration and during startup')
self.ae(message, 'In file /some/kitty.conf:\n3:invalid in line: font_size x\n\nOther errors:\nstartup error')
def test_watcher_iterable(self):
for container in (list, tuple, iter):