Skip to main content

uv_distribution_types/
error.rs

1use std::path::PathBuf;
2use uv_normalize::PackageName;
3use uv_redacted::DisplaySafeUrl;
4
5#[derive(thiserror::Error, Debug)]
6pub enum Error {
7    #[error(transparent)]
8    Io(#[from] std::io::Error),
9
10    #[error(transparent)]
11    Utf8(#[from] std::str::Utf8Error),
12
13    #[error(transparent)]
14    WheelFilename(#[from] uv_distribution_filename::WheelFilenameError),
15
16    #[error("Could not extract path segments from URL: {0}")]
17    MissingPathSegments(String),
18
19    #[error("Could not extract wheel filename from path: {}", _0.display())]
20    MissingWheelFilename(PathBuf),
21
22    #[error("Distribution not found at: {0}")]
23    NotFound(DisplaySafeUrl),
24
25    #[error("Requested package name `{0}` does not match `{1}` in the distribution filename: {2}")]
26    PackageNameMismatch(PackageName, PackageName, String),
27
28    #[error(
29        "Source distribution `{0}` has a non-PEP 625-compliant filename; only `.tar.gz` and `.zip` archives are accepted"
30    )]
31    NotPep625Filename(String),
32}