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 model is gated: either no token was supplied, or the token that was
22    /// supplied has not been granted access to this repo.
23    #[error(
24        "{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`)."
25    )]
26    AuthRequired(String),
27    /// Not enough free disk space to complete the download.
28    #[error(
29        "Not enough free disk space: this model needs {} and {} is available.",
30        format_bytes(*required_bytes),
31        format_bytes(*available_bytes)
32    )]
33    InsufficientDisk {
34        /// Bytes the model needs.
35        required_bytes: i64,
36        /// Bytes currently free.
37        available_bytes: i64,
38    },
39    /// A downloaded file failed checksum verification.
40    #[error("{0} failed checksum verification after download.")]
41    ChecksumMismatch(String),
42    /// The transfer failed with a message.
43    #[error("{0}")]
44    TransferFailed(String),
45}