Skip to content

fix: handle user abort (Ctrl+C) gracefully#234

Merged
JannikSt merged 1 commit intomainfrom
fix/handle-user-abort-gracefully
Dec 3, 2025
Merged

fix: handle user abort (Ctrl+C) gracefully#234
JannikSt merged 1 commit intomainfrom
fix/handle-user-abort-gracefully

Conversation

@JannikSt
Copy link
Copy Markdown
Member

@JannikSt JannikSt commented Dec 3, 2025

Summary

  • Catch typer.Abort exceptions to show a clean "Operation cancelled" message instead of ugly tracebacks when users press Ctrl+C during interactive prompts
  • Added global handler in main.py for CLI-wide coverage
  • Added specific handlers in pods.py for create and connect commands (which have their own exception handling blocks)

Before

Select GPU type number [1]: ^C
Unexpected error: 
Traceback (most recent call last):
  File ".../pods.py", line 476, in create
    gpu_type_idx = typer.prompt("Select GPU type number", type=int, default=1)
  ...
click.exceptions.Abort

After

Select GPU type number [1]: ^C
Operation cancelled

Test plan

  • Run prime pods create, press Ctrl+C during prompt - should show clean message
  • Verify exit code is 0 (clean exit) instead of 1 (error)
  • Existing tests pass

Fixes #34


Note

Catch typer.Abort to show a clean "Operation cancelled" message and exit 0 in the CLI entrypoint and pods create/connect commands.

  • CLI:
    • Add global typer.Abort handler in prime_cli/main.py:run() to print "Operation cancelled" and exit 0.
  • Pods Commands (prime_cli/commands/pods.py):
    • create: Catch typer.Abort, print "Operation cancelled", exit 0.
    • connect (aka ssh): Catch typer.Abort, print "Operation cancelled", exit 0.

Written by Cursor Bugbot for commit 848e6de. This will update automatically on new commits. Configure here.

When users cancel interactive prompts with Ctrl+C, the CLI now shows
a clean "Operation cancelled" message instead of an ugly exception
traceback.

Fixes #34
@JannikSt JannikSt mentioned this pull request Dec 3, 2025
@JannikSt JannikSt merged commit 8996c08 into main Dec 3, 2025
11 checks passed
@JannikSt JannikSt deleted the fix/handle-user-abort-gracefully branch December 3, 2025 08:12
@JannikSt JannikSt mentioned this pull request Dec 4, 2025
4 tasks
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.

Aborts currently cause ugly exceptions

1 participant