fix: logic to handle interrupt before timeout in error checking (#918)

- Reorder conditions to check ErrInterrupted before ErrProgramKilled
- Prevents Ctrl+C from being incorrectly treated as timeout
This commit is contained in:
arithmeticmean 2025-06-10 22:56:28 +05:30 committed by GitHub
commit 8081f74c4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -78,13 +78,13 @@ func main() {
if errors.As(err, &ex) {
os.Exit(int(ex))
}
if errors.Is(err, tea.ErrInterrupted) {
os.Exit(exit.StatusAborted)
}
if errors.Is(err, tea.ErrProgramKilled) {
fmt.Fprintln(os.Stderr, "timed out")
os.Exit(exit.StatusTimeout)
}
if errors.Is(err, tea.ErrInterrupted) {
os.Exit(exit.StatusAborted)
}
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}