Skip to content

Model final command errors explicitly - #20188

Merged
zanieb merged 1 commit into
mainfrom
zb/explicit-user-failures
Jul 7, 2026
Merged

Model final command errors explicitly#20188
zanieb merged 1 commit into
mainfrom
zb/explicit-user-failures

Conversation

@zanieb

@zanieb zanieb commented Jul 7, 2026

Copy link
Copy Markdown
Member

Keep ExitStatus code-only and represent propagated command errors explicitly as UvError::User or UvError::Unexpected. Command handlers classify and propagate their errors; the entrypoint renders user errors as a single line with exit code 1 and renders unclassified error chains with exit code 2. This preserves the existing default text and exit codes while providing a behavior-focused alternative to the error-carrying ExitStatus introduced in #20114.

The stacked follow-up #20163 routes this centralized rendering through Printer and defines the resulting -q and -qq behavior.

Part of #17110.

@zanieb
zanieb force-pushed the zb/explicit-user-failures branch from d625418 to 34ea105 Compare July 7, 2026 15:09
@zanieb
zanieb force-pushed the zb/explicit-user-failures branch from 34ea105 to 3789bd8 Compare July 7, 2026 15:26
@zanieb zanieb changed the title Model final command failures explicitly Model final command errors explicitly Jul 7, 2026
Comment thread crates/uv/src/commands/project/sync.rs Outdated
@zanieb
zanieb force-pushed the zb/explicit-user-failures branch 2 times, most recently from bf5c297 to 63f741c Compare July 7, 2026 15:43
@zanieb
zanieb changed the base branch from charlie/operation-diagnostic-printer to main July 7, 2026 15:43
@astral-sh-bot

astral-sh-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

uv test inventory changes

This PR changes the tests when compared with the latest main baseline.

  • Added tests: 0
  • Removed tests: 2
  • Changed suites: 1
uv-shell: +0 / -2

Added: none

Removed:

  • uv-shell::shlex::tests::escape_posix_borrows_unchanged_strings
  • uv-shell::tests::shell_escape_borrows_unchanged_strings

@zanieb
zanieb marked this pull request as ready for review July 7, 2026 17:10
@zanieb
zanieb force-pushed the zb/explicit-user-failures branch from 4320d74 to c3b9f91 Compare July 7, 2026 17:42
@zanieb
zanieb merged commit da1613b into main Jul 7, 2026
57 checks passed
@zanieb
zanieb deleted the zb/explicit-user-failures branch July 7, 2026 18:38
@zanieb zanieb added the internal A refactor or improvement that is not user-facing label Jul 7, 2026
zanieb added a commit that referenced this pull request Jul 7, 2026
Render final `UvError` values through `Printer` at the command
entrypoint. The default error-chain renderer accepts the `Printer`
directly and owns hint collection and stream selection; `-q` preserves
final errors and `-qq` suppresses them while exit codes remain 1 for
user errors and 2 for unexpected errors. Stacked on #20188.

Part of #17110.
Closes #19326.
zanieb added a commit that referenced this pull request Jul 7, 2026
Our trace log that emits a debug representation of errors is useless for
`anyhow::Error` which is more common following
#20188.

For `UvError::User`, we elide the trace log entirely, I do not expect us
to need to debug those error chains.

For `UvError::Unexpected`, we introduce a new
`uv_errors::debug_error_chain` formatter that walks each source and
renders its `Debug` representation. To retain parity with the previous
implementation, we also log the backtrace if available.

e.g.:

```diff
-TRACE Error trace: Failed to create virtual environment
-
-Caused by:
-    Not a directory (os error 20)
+TRACE Error chain:
+0: Creation(Io(Os { code: 20, kind: NotADirectory, message: "Not a directory" }))
+1: Io(Os { code: 20, kind: NotADirectory, message: "Not a directory" })
 error: Failed to create virtual environment
   Caused by: Not a directory (os error 20)
```
@zanieb zanieb mentioned this pull request Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user-facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant