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