Skip to content

Route final errors through the printer - #20114

Closed
charliermarsh wants to merge 3 commits into
charlie/operation-diagnostic-printerfrom
charlie/final-error-output
Closed

charliermarsh wants to merge 3 commits into
charlie/operation-diagnostic-printerfrom
charlie/final-error-output

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Jul 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Final command errors currently take two paths: returned anyhow::Error values are rendered by the top-level entry point, while expected validation failures print directly and return a bare ExitStatus. The top-level renderer bypasses Printer, so -qq still emits errors, while lockfile mismatch messages use ordinary stderr and disappear under -q.

This separates the process exit code from an optional final error in ExitStatus and renders final errors through stderr_important(). Lockfile mismatch paths now return their error instead of printing it, so final diagnostics remain visible under -q, are suppressed under -qq, and retain their existing exit codes: 1 for expected lock mismatches and 2 for unexpected command errors.

Closes #19326.

@charliermarsh charliermarsh added area:error-messages Messaging when something goes wrong breaking A breaking change labels Jul 4, 2026
@charliermarsh charliermarsh added this to the v0.12.0 milestone Jul 4, 2026
@charliermarsh
charliermarsh marked this pull request as ready for review July 4, 2026 15:27
@charliermarsh
charliermarsh marked this pull request as draft July 4, 2026 15:28
@charliermarsh
charliermarsh marked this pull request as ready for review July 4, 2026 15:37
@astral-sh-bot

astral-sh-bot Bot commented Jul 4, 2026

Copy link
Copy Markdown

uv test inventory changes

This PR changes the tests when compared with the latest charlie/operation-diagnostic-printer baseline.

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

Added:

  • uv::lock::lock::locked_quiet_modes

Removed: none

uv::workspace: +1 / -0

Added:

  • uv::workspace::workspace_metadata::workspace_metadata_locked_quiet_modes

Removed: none

@zsol
zsol self-requested a review July 6, 2026 14:49
@zanieb

zanieb commented Jul 6, 2026

Copy link
Copy Markdown
Member

This has some interactions with the miette removal work, I'll see if they're problematic.

Comment on lines -206 to -215
impl From<ExitStatus> for ExitCode {
fn from(status: ExitStatus) -> Self {
match status {
ExitStatus::Success => Self::from(0),
ExitStatus::Failure => Self::from(1),
ExitStatus::Error => Self::from(2),
ExitStatus::External(code) => Self::from(code),
}
}
}

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.

Why does this go away?

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.

Comment thread crates/uv/src/lib.rs
.expect("writing to stderr should not fail");

ExitStatus::Error.into()
ExitCode::from(2)

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.

I am a bit sad we can't reuse our constant definition here

@zsol zsol 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, but no idea about the miette interactions so you might want to wait for Zanie before merging

@konstin konstin mentioned this pull request Jul 7, 2026
zanieb added a commit that referenced this pull request Jul 7, 2026
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 commented Jul 7, 2026

Copy link
Copy Markdown
Member

I'm going to go with my approach instead, though time may tell that it's not any better :)

@zanieb zanieb closed this Jul 7, 2026
@charliermarsh

Copy link
Copy Markdown
Member Author

Sounds great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:error-messages Messaging when something goes wrong breaking A breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants