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
This commit is contained in:
15
ui.py
15
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)
|
||||
|
||||
Reference in New Issue
Block a user