Skip to main content

kernel/install/
error.rs

1//! Install failures.
2
3use crate::install::provider::InstallProviderId;
4use crate::records::format_bytes;
5
6/// Why a model install could not proceed or complete.
7#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
8pub enum InstallError {
9    /// No provider is registered under this id.
10    #[error("No install provider is registered as {0}.")]
11    ProviderUnknown(InstallProviderId),
12    /// The provider exists but can't be used (with a reason).
13    #[error("{0}")]
14    ProviderUnavailable(String),
15    /// The reference isn't one this provider understands.
16    #[error("{0} is not a reference this provider understands.")]
17    ReferenceInvalid(String),
18    /// The reference was not found on the platform.
19    #[error("{0} was not found on the platform.")]
20    ReferenceNotFound(String),
21    /// The platform would not show or serve what was asked, and this says why:
22    /// a repo it will not show an anonymous client, a token it rejected. A fact
23    /// about the account in hand, not about the network.
24    #[error("{0}")]
25    AccessDenied(String),
26    /// The model is gated: either no token was supplied, or the token that was
27    /// supplied has not been granted access to this repo.
28    #[error(
29        "{0} is gated. Accept its terms and request access at https://huggingface.co/{0}, then set HF_TOKEN to a token with read access (or sign in with `huggingface-cli login`)."
30    )]
31    AuthRequired(String),
32    /// Not enough free disk space to complete the download.
33    #[error(
34        "Not enough free disk space: this model needs {} and {} is available.",
35        format_bytes(*required_bytes),
36        format_bytes(*available_bytes)
37    )]
38    InsufficientDisk {
39        /// Bytes the model needs.
40        required_bytes: i64,
41        /// Bytes currently free.
42        available_bytes: i64,
43    },
44    /// A downloaded file failed checksum verification.
45    #[error("{0} failed checksum verification after download.")]
46    ChecksumMismatch(String),
47    /// The transfer failed with a message.
48    #[error("{0}")]
49    TransferFailed(String),
50    /// Something on this machine refused: a directory that cannot be written,
51    /// a file that cannot be read. Unlike a transfer failure, trying again
52    /// without changing anything will not help.
53    #[error("{0}")]
54    Local(String),
55}