From 16b5209338b3c79278e72e58f275cfe18fa772b5 Mon Sep 17 00:00:00 2001 From: pfl Date: Fri, 9 Jan 2026 13:56:14 +0100 Subject: [PATCH] Fix exception handling in ui.py - Replace 6 bare except: with except curses.error: - Remove inline import logging, use module-level logger - Improves safety by not catching KeyboardInterrupt/SystemExit --- ui.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ui.py b/ui.py index 43446a0..7957f20 100644 --- a/ui.py +++ b/ui.py @@ -105,7 +105,7 @@ def update_autocomplete_display(window, current_input, first_word, words, ends_w else: window.addstr(1, x_pos, arg_text, curses.A_DIM) x_pos += len(arg_text) + 1 - except: + except curses.error: pass else: # User is typing arguments @@ -134,7 +134,7 @@ def update_autocomplete_display(window, current_input, first_word, words, ends_w match_line = f'<{arg_type}>: {" ".join(display_suggestions)}{more_indicator}' try: window.addstr(1, 0, match_line, curses.A_DIM) - except: + except curses.error: pass suggestions = arg_suggestions # Store for Tab cycling suggestion_index = -1 @@ -151,7 +151,7 @@ def update_autocomplete_display(window, current_input, first_word, words, ends_w else: window.addstr(1, x_pos, arg_text, curses.A_DIM) x_pos += len(arg_text) + 1 - except: + except curses.error: pass elif first_word in COMMAND_SIGNATURES and COMMAND_SIGNATURES[first_word]: @@ -166,7 +166,7 @@ def update_autocomplete_display(window, current_input, first_word, words, ends_w else: window.addstr(1, x_pos, arg_text, curses.A_DIM) x_pos += len(arg_text) + 1 - except: + except curses.error: pass else: @@ -180,7 +180,7 @@ def update_autocomplete_display(window, current_input, first_word, words, ends_w match_line = ' '.join(suggestions) try: window.addstr(1, 0, match_line, curses.A_DIM) - except: + except curses.error: pass return suggestions, suggestion_index, original_word @@ -367,7 +367,7 @@ class UIManager: try: window.addstr(1, 0, display_line, curses.A_DIM) - except: + except curses.error: pass window.move(0, cursor_pos) @@ -496,8 +496,7 @@ class UIManager: curses.doupdate() # Immediate screen update except Exception as e: - import logging - logging.getLogger('ui').error(f'Input error: {e}') + logger.error(f'Input error: {e}') # Log but continue - input thread should stay alive window.move(0, cursor_pos)