#[non_exhaustive]pub enum Error {
Show 21 variants
Http(Error),
Json(Error),
Url(ParseError),
InvalidHeader(InvalidHeaderValue),
RateLimitExceeded {
retry_after_secs: Option<u64>,
limit: Option<u32>,
remaining: Option<u32>,
},
ApiStatus(Box<ApiStatusError>),
InvalidInput(String),
Io(Error),
Base64(Box<dyn Error + Send + Sync>),
Xml(Box<dyn Error + Send + Sync>),
XstsRejected(Box<XstsError>),
MissingUserHash,
DeviceCodeExpired,
DeviceCodeDeclined,
DoesNotOwnMinecraft,
MissingTexturesProperty,
Yggdrasil(Box<YggdrasilError>),
InvalidAliLocation,
MissingSignature(String),
InvalidSignature(String),
BlessingApi {
code: i32,
message: String,
},
}Expand description
Unified error type returned across all mcapi modules.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Http(Error)
http only.Underlying HTTP transport or request execution failure.
Json(Error)
JSON serialization or deserialization failure.
Url(ParseError)
http only.URL parsing failure.
InvalidHeader(InvalidHeaderValue)
http only.Invalid HTTP header value supplied by caller or server response.
RateLimitExceeded
http only.HTTP 429 Too Many Requests response when rate-limit retries are disabled or exhausted.
Fields
ApiStatus(Box<ApiStatusError>)
http only.Non-success HTTP status response returned by an API endpoint.
InvalidInput(String)
Caller-supplied argument failed validation or precondition checks.
Io(Error)
Filesystem or stream I/O failure.
Base64(Box<dyn Error + Send + Sync>)
profile only.Opaque Base64 decoding failure (e.g. malformed textures property or signature).
Xml(Box<dyn Error + Send + Sync>)
loaders only.Opaque XML parsing failure (e.g. malformed Maven metadata XML).
XstsRejected(Box<XstsError>)
mojang only.Xbox Live XSTS authorization rejected with an XErr code.
MissingUserHash
mojang only.Xbox Live / XSTS DisplayClaims omitted the required uhs user hash.
DeviceCodeExpired
mojang only.Microsoft OAuth2 device code expired before the user completed authorization.
DeviceCodeDeclined
mojang only.User explicitly declined Microsoft OAuth2 device code authorization.
DoesNotOwnMinecraft
mojang only.Authenticated Microsoft account does not own Minecraft: Java Edition.
MissingTexturesProperty
mojang or yggdrasil only.Profile properties did not contain a "textures" entry.
Yggdrasil(Box<YggdrasilError>)
yggdrasil only.Yggdrasil server returned a structured JSON error response.
InvalidAliLocation
yggdrasil only.X-Authlib-Injector-API-Location header was invalid, circular, or attempted an HTTPS-to-HTTP downgrade.
MissingSignature(String)
yggdrasil-verify only.Required RSA signature was absent from a profile property.
InvalidSignature(String)
yggdrasil-verify only.RSA public key PEM or property signature verification failed.
BlessingApi
blessing only.Blessing Skin API returned a non-zero error code, or code == 0 with a missing
expected data payload.
Implementations§
Source§impl Error
impl Error
Sourcepub fn status_code(&self) -> Option<u16>
pub fn status_code(&self) -> Option<u16>
Returns the HTTP status code associated with this error, if any.
Returns Some(status) for Error::ApiStatus and Some(429) for
Error::RateLimitExceeded.
Sourcepub fn api_status_error(&self) -> Option<&ApiStatusError>
Available on crate feature http only.
pub fn api_status_error(&self) -> Option<&ApiStatusError>
http only.Returns the structured ApiStatusError payload if this is Error::ApiStatus.
Sourcepub fn yggdrasil_error(&self) -> Option<&YggdrasilError>
Available on crate feature yggdrasil only.
pub fn yggdrasil_error(&self) -> Option<&YggdrasilError>
yggdrasil only.Returns the structured YggdrasilError payload if this is Error::Yggdrasil.
Sourcepub fn xsts_error(&self) -> Option<&XstsError>
Available on crate feature mojang only.
pub fn xsts_error(&self) -> Option<&XstsError>
mojang only.Returns the structured XstsError payload if this is Error::XstsRejected.
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
Returns true if this error represents an HTTP 404 Not Found response.
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
Returns true if this error represents an HTTP 429 Too Many Requests response.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()