#[non_exhaustive]pub enum HFError {
Show 21 variants
Http {
context: Box<HttpErrorContext>,
},
AuthRequired {
context: Box<HttpErrorContext>,
},
RepoNotFound {
repo_id: String,
context: Option<Box<HttpErrorContext>>,
},
RevisionNotFound {
repo_id: String,
revision: String,
context: Option<Box<HttpErrorContext>>,
},
EntryNotFound {
path: String,
repo_id: String,
context: Option<Box<HttpErrorContext>>,
},
BucketNotFound {
bucket_id: String,
context: Option<Box<HttpErrorContext>>,
},
Forbidden {
context: Box<HttpErrorContext>,
},
Conflict {
context: Box<HttpErrorContext>,
},
RateLimited {
retry_after: Option<Duration>,
context: Box<HttpErrorContext>,
},
LocalEntryNotFound {
path: String,
},
CacheNotEnabled,
CacheLockTimeout {
path: PathBuf,
},
Request {
source: Error,
url: Option<String>,
},
Io(Error),
Json(Error),
Url(ParseError),
InvalidParameter(String),
DiffParse(HFDiffParseError),
Xet {
operation: XetOperation,
source: Box<dyn Error + Send + Sync>,
},
MalformedResponse {
what: String,
url: Option<String>,
},
Other(String),
}Expand description
Error type returned by public hf-hub APIs.
Match on the specific variants first for common Hub cases such as
authentication, missing repos/files/revisions, forbidden access, and rate
limiting. Lower-level transport failures use HFError::Request, while
unmapped HTTP responses use HFError::Http.
This enum is #[non_exhaustive]: external matches must include a wildcard
arm so new variants can be added without a SemVer break.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Http
Non-success HTTP response that was not mapped to a more specific variant.
AuthRequired
Authentication is required or the configured token was rejected.
RepoNotFound
Repository was not found.
Fields
RevisionNotFound
Revision was not found within a repository.
Fields
EntryNotFound
File or path was not found within a repository or bucket.
Fields
BucketNotFound
Bucket was not found.
Fields
Forbidden
Credentials are valid, but the caller is not allowed to perform the operation.
Conflict
Server reported a conflict, such as an already-existing resource or a branch head mismatch.
RateLimited
Request was rate limited by the Hub.
Fields
LocalEntryNotFound
File was not found in the local cache during a cache-only lookup.
CacheNotEnabled
The operation requires the local cache, but caching is disabled.
CacheLockTimeout
Timed out waiting for an on-disk cache lock.
Request
Transport-level HTTP client error before a usable Hub response was produced.
Fields
Io(Error)
Filesystem I/O error.
Json(Error)
JSON serialization or deserialization error.
Url(ParseError)
URL parsing error.
InvalidParameter(String)
Caller provided an invalid parameter value.
DiffParse(HFDiffParseError)
Raw diff parsing error.
Xet
A xet (high-performance content-addressable) operation failed.
The operation field identifies which step
failed; source carries the underlying error
(typically a xet_core error or a tokio join failure).
Fields
operation: XetOperationWhich xet operation produced the error.
MalformedResponse
Hub responded with success but the response is missing data the client
needs to proceed (e.g., an ETag or X-Repo-Commit header that should
always be present, or a 304 Not Modified without a corresponding
cached state).
Distinct from Http: the status code was a success, the
shape of the response was wrong.
Fields
Other(String)
Catch-all error for cases that do not fit another variant.
Implementations§
Source§impl HFError
impl HFError
Sourcepub fn xet<E>(operation: XetOperation, source: E) -> Self
pub fn xet<E>(operation: XetOperation, source: E) -> Self
Construct an HFError::Xet from a typed source error.
The source is type-erased into Box<dyn Error + Send + Sync> so that
upstream xet_core types stay out of the public API; downstream
matchers can use source.downcast_ref::<T>() if they need the concrete
type.
Sourcepub fn malformed_response(what: impl Into<String>) -> Self
pub fn malformed_response(what: impl Into<String>) -> Self
Construct a HFError::MalformedResponse without a known URL.
Sourcepub fn malformed_response_at(
what: impl Into<String>,
url: impl Into<String>,
) -> Self
pub fn malformed_response_at( what: impl Into<String>, url: impl Into<String>, ) -> Self
Construct a HFError::MalformedResponse with the originating URL attached.
Trait Implementations§
Source§impl Error for HFError
impl Error for HFError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<HFDiffParseError> for HFError
impl From<HFDiffParseError> for HFError
Source§fn from(source: HFDiffParseError) -> Self
fn from(source: HFDiffParseError) -> Self
Source§impl From<ParseError> for HFError
impl From<ParseError> for HFError
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for HFError
impl !UnwindSafe for HFError
impl Freeze for HFError
impl Send for HFError
impl Sync for HFError
impl Unpin for HFError
impl UnsafeUnpin for HFError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<E> ResultError for E
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.