mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-03 21:23:54 +00:00
Use display representation for download error (#5173)
## Summary Turns out we already have display for this. Closes https://github.com/astral-sh/uv/issues/4914.
This commit is contained in:
parent
91bf213641
commit
564f4b2958
4 changed files with 8 additions and 8 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -4934,6 +4934,7 @@ dependencies = [
|
||||||
"install-wheel-rs",
|
"install-wheel-rs",
|
||||||
"itertools 0.13.0",
|
"itertools 0.13.0",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
"owo-colors",
|
||||||
"pep440_rs",
|
"pep440_rs",
|
||||||
"pep508_rs",
|
"pep508_rs",
|
||||||
"platform-tags",
|
"platform-tags",
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ fs-err = { workspace = true, features = ["tokio"] }
|
||||||
futures = { workspace = true }
|
futures = { workspace = true }
|
||||||
itertools = { workspace = true }
|
itertools = { workspace = true }
|
||||||
once_cell = { workspace = true }
|
once_cell = { workspace = true }
|
||||||
|
owo-colors = { workspace = true }
|
||||||
regex = { workspace = true }
|
regex = { workspace = true }
|
||||||
reqwest = { workspace = true }
|
reqwest = { workspace = true }
|
||||||
reqwest-middleware = { workspace = true }
|
reqwest-middleware = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ use std::str::FromStr;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
|
use owo_colors::OwoColorize;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tokio::io::{AsyncRead, ReadBuf};
|
use tokio::io::{AsyncRead, ReadBuf};
|
||||||
use tokio_util::compat::FuturesAsyncReadCompatExt;
|
use tokio_util::compat::FuturesAsyncReadCompatExt;
|
||||||
|
|
@ -30,9 +31,9 @@ pub enum Error {
|
||||||
IO(#[from] io::Error),
|
IO(#[from] io::Error),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
ImplementationError(#[from] ImplementationError),
|
ImplementationError(#[from] ImplementationError),
|
||||||
#[error("Invalid python version: {0}")]
|
#[error("Invalid Python version: {0}")]
|
||||||
InvalidPythonVersion(String),
|
InvalidPythonVersion(String),
|
||||||
#[error("Invalid request key, too many parts: {0}")]
|
#[error("Invalid request key (too many parts): {0}")]
|
||||||
TooManyParts(String),
|
TooManyParts(String),
|
||||||
#[error("Download failed")]
|
#[error("Download failed")]
|
||||||
NetworkError(#[from] WrappedReqwestError),
|
NetworkError(#[from] WrappedReqwestError),
|
||||||
|
|
@ -48,7 +49,7 @@ pub enum Error {
|
||||||
expected: String,
|
expected: String,
|
||||||
actual: String,
|
actual: String,
|
||||||
},
|
},
|
||||||
#[error("Invalid download url")]
|
#[error("Invalid download URL")]
|
||||||
InvalidUrl(#[from] url::ParseError),
|
InvalidUrl(#[from] url::ParseError),
|
||||||
#[error("Failed to create download directory")]
|
#[error("Failed to create download directory")]
|
||||||
DownloadDirError(#[source] io::Error),
|
DownloadDirError(#[source] io::Error),
|
||||||
|
|
@ -64,12 +65,9 @@ pub enum Error {
|
||||||
#[source]
|
#[source]
|
||||||
err: io::Error,
|
err: io::Error,
|
||||||
},
|
},
|
||||||
#[error("Failed to parse managed Python directory name: {0}")]
|
|
||||||
NameError(String),
|
|
||||||
#[error("Failed to parse request part")]
|
#[error("Failed to parse request part")]
|
||||||
InvalidRequestPlatform(#[from] platform::Error),
|
InvalidRequestPlatform(#[from] platform::Error),
|
||||||
// TODO(zanieb): Implement display for `PythonDownloadRequest`
|
#[error("No download found for request: {}", _0.green())]
|
||||||
#[error("No download found for request: {0:?}")]
|
|
||||||
NoDownloadFound(PythonDownloadRequest),
|
NoDownloadFound(PythonDownloadRequest),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ pub(crate) async fn install(
|
||||||
.find(|installation| download_request.satisfied_by_key(installation.key()))
|
.find(|installation| download_request.satisfied_by_key(installation.key()))
|
||||||
{
|
{
|
||||||
if matches!(request, PythonRequest::Any) {
|
if matches!(request, PythonRequest::Any) {
|
||||||
writeln!(printer.stderr(), "Found: {}", installation.key().green(),)?;
|
writeln!(printer.stderr(), "Found: {}", installation.key().green())?;
|
||||||
} else {
|
} else {
|
||||||
writeln!(
|
writeln!(
|
||||||
printer.stderr(),
|
printer.stderr(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue