mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-02 12:59:45 +00:00
Improve error message when editable requirement doesn't exist (#1024)
Making these a lot clearer in the common case by reducing the depth of the error.
This commit is contained in:
parent
53b7e3cb4f
commit
d9cc9dbf88
7 changed files with 34 additions and 18 deletions
|
|
@ -11,6 +11,6 @@ pub enum Error {
|
|||
#[error("Unable to extract filename from URL: {0}")]
|
||||
UrlFilename(Url),
|
||||
|
||||
#[error("Unable to locate distribution at: {0}")]
|
||||
NotFound(Url, #[source] std::io::Error),
|
||||
#[error("Distribution not found at: {0}")]
|
||||
NotFound(Url),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,12 +228,19 @@ impl Dist {
|
|||
}
|
||||
|
||||
if url.scheme().eq_ignore_ascii_case("file") {
|
||||
// Store the canonicalized path.
|
||||
let path = url
|
||||
// Store the canonicalized path, which also serves to validate that it exists.
|
||||
let path = match url
|
||||
.to_file_path()
|
||||
.map_err(|()| Error::UrlFilename(url.to_url()))?
|
||||
.canonicalize()
|
||||
.map_err(|err| Error::NotFound(url.to_url(), err))?;
|
||||
{
|
||||
Ok(path) => path,
|
||||
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
|
||||
return Err(Error::NotFound(url.to_url()));
|
||||
}
|
||||
Err(err) => return Err(err.into()),
|
||||
};
|
||||
|
||||
return if path
|
||||
.extension()
|
||||
.is_some_and(|ext| ext.eq_ignore_ascii_case("whl"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue