Skip to content

Conversation

biniabokouame
Copy link

Improved Error Handling for the khal new -i Command

Identified Issue
When creating an event interactively with khal new -i, an error in one field (e.g., datetime range) forces the user to restart the entire input process, even if other fields are correct. This makes the user experience frustrating and inefficient.

Proposed Solution
This fix improves the new_interactive function by:

  1. Handling errors iteratively:
    • When an invalid input is detected, the user receives a clear error message and can correct only the problematic field.
  2. Allowing cancellation:
    • If the user enters an empty value, the process is canceled without restarting the application.
  3. Simplifying the user experience:
    • Valid data is retained, and only the incorrect fields are re-entered.

Changes Made

  • Added a while True loop to manage field validation one by one.
  • Error handling with a try-except block to capture and display error messages.
  • The user can cancel event creation by entering an empty field.

Benefits

  • Enhances the user experience during interactive input.
  • Reduces frustration caused by repeated errors.
  • Provides a flexible and intuitive way to correct invalid inputs.

Testing Instructions

  1. Run the khal new -i command.
  2. Provide valid fields and one invalid field (e.g., datetime range: 3d).
  3. Verify that:
    • An error message is shown for the invalid field.
    • The user can correct only that field without losing valid data.
    • Event creation continues once the input is corrected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant