Handle set colors exceptions

This commit is contained in:
pagedown 2021-11-03 12:55:05 +08:00
parent 477baf390b
commit 40ff78b1c8
No known key found for this signature in database
GPG key ID: E921CF18AC8FF6EB
2 changed files with 8 additions and 1 deletions

View file

@ -1875,7 +1875,11 @@ def set_colors(self, *args: str) -> None:
except (Exception, SystemExit) as err:
self.show_error('Invalid set_colors mapping', str(err))
return
payload = c.message_to_kitty(parse_rc_args([])[0], opts, items)
try:
payload = c.message_to_kitty(parse_rc_args([])[0], opts, items)
except (Exception, SystemExit) as err:
self.show_error('Failed to set colors', str(err))
return
c.response_from_kitty(self, self.active_window, PayloadGetter(c, payload if isinstance(payload, dict) else {}))
def _move_window_to(

View file

@ -5,6 +5,7 @@
import os
from typing import TYPE_CHECKING, Dict, Iterable, Optional
from kitty.cli import emph
from kitty.config import parse_config
from kitty.fast_data_types import patch_color_profiles, Color
@ -95,6 +96,8 @@ def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: Arg
if not opts.reset:
try:
final_colors = parse_colors(args)
except FileNotFoundError as err:
raise ParsingOfArgsFailed(f'The colors configuration file {emph(err.filename)} was not found.') from err
except Exception as err:
raise ParsingOfArgsFailed(str(err)) from err
ans = {