mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-17 18:57:30 +00:00
Dedicated error type for direct url parsing (#3181)
Add a dedicated error type for direct url parsing. This change is broken out from the new uv requirement type, which uses direct url parsing internally.
This commit is contained in:
parent
0e54cfb019
commit
f29c991e21
7 changed files with 38 additions and 17 deletions
|
|
@ -3,6 +3,7 @@ use tokio::task::JoinError;
|
|||
use zip::result::ZipError;
|
||||
|
||||
use distribution_filename::WheelFilenameError;
|
||||
use distribution_types::DirectUrlError;
|
||||
use pep440_rs::Version;
|
||||
use pypi_types::HashDigest;
|
||||
use uv_client::BetterReqwestError;
|
||||
|
|
@ -23,6 +24,8 @@ pub enum Error {
|
|||
#[error("Git operation failed")]
|
||||
Git(#[source] anyhow::Error),
|
||||
#[error(transparent)]
|
||||
DirectUrl(#[from] Box<DirectUrlError>),
|
||||
#[error(transparent)]
|
||||
Reqwest(#[from] BetterReqwestError),
|
||||
#[error(transparent)]
|
||||
Client(#[from] uv_client::Error),
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ pub(crate) async fn fetch_git_archive(
|
|||
)
|
||||
.map_err(Error::CacheWrite)?;
|
||||
|
||||
let DirectGitUrl { url, subdirectory } = DirectGitUrl::try_from(url).map_err(Error::Git)?;
|
||||
let DirectGitUrl { url, subdirectory } = DirectGitUrl::try_from(url).map_err(Box::new)?;
|
||||
|
||||
// Fetch the Git repository.
|
||||
let source = if let Some(reporter) = reporter {
|
||||
|
|
@ -95,7 +95,7 @@ pub(crate) async fn resolve_precise(
|
|||
cache: &Cache,
|
||||
reporter: Option<&Arc<dyn Reporter>>,
|
||||
) -> Result<Option<Url>, Error> {
|
||||
let DirectGitUrl { url, subdirectory } = DirectGitUrl::try_from(url).map_err(Error::Git)?;
|
||||
let DirectGitUrl { url, subdirectory } = DirectGitUrl::try_from(url).map_err(Box::new)?;
|
||||
|
||||
// If the Git reference already contains a complete SHA, short-circuit.
|
||||
if url.precise().is_some() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue