crates_index/
error.rs

1pub use serde_json::Error as SerdeJsonError;
2use std::io;
3use std::path::PathBuf;
4pub use toml::de::Error as TomlDeError;
5
6/// The catch-all error for the entire crate.
7#[derive(Debug, thiserror::Error)]
8#[allow(missing_docs)]
9pub enum Error {
10    #[error("\"gix\" crate failed. If problems persist, consider deleting `~/.cargo/registry/index/github.com-1ecc6299db9ec823/`")]
11    #[cfg(feature = "git")]
12    Git(#[from] GixError),
13    #[error("{0}")]
14    Url(String),
15    #[error("Could not obtain the most recent head commit in repo at {}. Tried {}, had {} available", repo_path.display(), refs_tried.join(", "), refs_available.join(", "))]
16    MissingHead {
17        /// The references we tried to get commits for.
18        refs_tried: &'static [&'static str],
19        /// The references that were actually present in the repository.
20        refs_available: Vec<String>,
21        /// The path of the repository we tried
22        repo_path: PathBuf,
23    },
24    #[error(transparent)]
25    Io(#[from] io::Error),
26    #[error("If this happens, the registry is seriously corrupted. Consider deleting `~/.cargo/registry/index/`")]
27    Json(#[from] SerdeJsonError),
28    #[error(transparent)]
29    Toml(#[from] TomlDeError),
30}
31
32/// Any error produced by `gix` or the `gix-*` family of crates.
33#[derive(Debug, thiserror::Error)]
34#[allow(missing_docs)]
35#[cfg(feature = "git")]
36pub enum GixError {
37    #[error(transparent)]
38    CreateInMemoryRemote(#[from] gix::remote::init::Error),
39    #[error(transparent)]
40    HeadCommit(#[from] gix::reference::head_commit::Error),
41    #[error(transparent)]
42    TreeOfCommit(#[from] gix::object::commit::Error),
43    #[error(transparent)]
44    DecodeObject(#[from] gix::objs::decode::Error),
45    #[error(transparent)]
46    FindExistingObject(#[from] gix::object::find::existing::Error),
47    #[error(transparent)]
48    FindObject(#[from] gix::object::find::Error),
49    #[error(transparent)]
50    IntoObjectKind(#[from] gix::object::try_into::Error),
51    #[error("The '{}' file is missing at the root of the tree of the crates index", path.display())]
52    PathMissing { path: std::path::PathBuf },
53    #[error(transparent)]
54    #[deprecated(note = "This variant can't happen anymore as locks aren't used when opening the index")]
55    LockAcquire(#[from] gix::lock::acquire::Error),
56    #[error(transparent)]
57    ParseRefSpec(#[from] gix::refspec::parse::Error),
58    #[error(transparent)]
59    RemoteConnect(#[from] gix::remote::connect::Error),
60    #[error(transparent)]
61    PrepareFetch(#[from] gix::remote::fetch::prepare::Error),
62    #[error(transparent)]
63    Fetch(#[from] gix::remote::fetch::Error),
64    #[error(transparent)]
65    PrepareClone(#[from] gix::clone::Error),
66    #[error(transparent)]
67    RemoteName(#[from] gix::remote::name::Error),
68    #[error(transparent)]
69    FetchDuringClone(#[from] gix::clone::fetch::Error),
70    #[error(transparent)]
71    PeelToKind(#[from] gix::object::peel::to_kind::Error),
72}
73
74/// Unknown error from [`crate::GitIndex::crates_parallel`]
75#[cfg(feature = "parallel")]
76#[derive(Debug, thiserror::Error)]
77#[error("error while iterating git repository")]
78pub struct CratesIterError;