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:
Charlie Marsh 2024-07-17 22:05:17 -04:00 committed by GitHub
parent 91bf213641
commit 564f4b2958
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 8 additions and 8 deletions

View file

@ -6,6 +6,7 @@ use std::str::FromStr;
use std::task::{Context, Poll};
use futures::TryStreamExt;
use owo_colors::OwoColorize;
use thiserror::Error;
use tokio::io::{AsyncRead, ReadBuf};
use tokio_util::compat::FuturesAsyncReadCompatExt;
@ -30,9 +31,9 @@ pub enum Error {
IO(#[from] io::Error),
#[error(transparent)]
ImplementationError(#[from] ImplementationError),
#[error("Invalid python version: {0}")]
#[error("Invalid Python version: {0}")]
InvalidPythonVersion(String),
#[error("Invalid request key, too many parts: {0}")]
#[error("Invalid request key (too many parts): {0}")]
TooManyParts(String),
#[error("Download failed")]
NetworkError(#[from] WrappedReqwestError),
@ -48,7 +49,7 @@ pub enum Error {
expected: String,
actual: String,
},
#[error("Invalid download url")]
#[error("Invalid download URL")]
InvalidUrl(#[from] url::ParseError),
#[error("Failed to create download directory")]
DownloadDirError(#[source] io::Error),
@ -64,12 +65,9 @@ pub enum Error {
#[source]
err: io::Error,
},
#[error("Failed to parse managed Python directory name: {0}")]
NameError(String),
#[error("Failed to parse request part")]
InvalidRequestPlatform(#[from] platform::Error),
// TODO(zanieb): Implement display for `PythonDownloadRequest`
#[error("No download found for request: {0:?}")]
#[error("No download found for request: {}", _0.green())]
NoDownloadFound(PythonDownloadRequest),
}