Skip to content

fix: unwrap inner TaskError code from TaskRunError - #3041

Merged
vmaerten merged 1 commit into
go-task:mainfrom
r3wretrhy:fix-prompt-cancel-exit-code
Sep 26, 2026
Merged

vmaerten merged 1 commit into
go-task:mainfrom
r3wretrhy:fix-prompt-cancel-exit-code

Conversation

@r3wretrhy

Copy link
Copy Markdown
Contributor

fix: unwrap inner TaskError code from TaskRunError

TaskCancelledByUserError.Code() is 205 (documented as "Task cancelled by user"), but RunTask wraps every body error in TaskRunError. cmd/task then type-asserts the outer error as TaskError and exits 201.

Keep the wrap (the "Failed to run task" prefix) and return the inner TaskError code when one is present. Command failures with no inner TaskError still exit 201.

go test ./errors/
ok

Fixes #3040

@vmaerten vmaerten self-assigned this Sep 20, 2026
@vmaerten
vmaerten self-requested a review September 23, 2026 13:47

@vmaerten vmaerten left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thanks!

@vmaerten
vmaerten merged commit 24c4ee6 into go-task:main Sep 26, 2026
17 checks passed
pull Bot pushed a commit to Mu-L/go-task that referenced this pull request Sep 27, 2026
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.

Prompt cancellation exits 201 instead of documented 205

2 participants