Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

context error is swallowed up, preventing errors.Is #1212

Open
goodevilgenius opened this issue Oct 29, 2024 · 0 comments
Open

context error is swallowed up, preventing errors.Is #1212

goodevilgenius opened this issue Oct 29, 2024 · 0 comments

Comments

@goodevilgenius
Copy link

Describe the bug
I should be able to use errors.Is to check the error returned by the context after p.Run. But that's broken.

Setup
Please complete the following information along with version numbers, if applicable.

  • OS Any
  • Shell Any
  • Terminal Emulator Any
  • Terminal Multiplexer Any

To Reproduce
Steps to reproduce the behavior:
See source code

Source Code

ctx := context.WithDeadline(context.Background, time.Second*5)
p := tea.NewProgram(model, tea.WithContext(ctx))
_, err := p.Run()
if errors.Is(err, context.DeadlineExceeded) {
  // Handle timeout
}

Expected behavior
If the five seconds pass during run (in this example), that if block should be executed.

Additional context

err = fmt.Errorf("%w: %s", ErrProgramKilled, p.ctx.Err())

On L598, change the format to "%w: %w", and that should work.

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 a pull request may close this issue.

1 participant