Skip to main content

Error

Enum Error 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Http(Error)

Available on crate feature http only.

Underlying HTTP transport or request execution failure.

§

Json(Error)

JSON serialization or deserialization failure.

§

Url(ParseError)

Available on crate feature http only.

URL parsing failure.

§

InvalidHeader(InvalidHeaderValue)

Available on crate feature http only.

Invalid HTTP header value supplied by caller or server response.

§

RateLimitExceeded

Available on crate feature http only.

HTTP 429 Too Many Requests response when rate-limit retries are disabled or exhausted.

Fields

§retry_after_secs: Option<u64>

Parsed wait duration in seconds from Retry-After / X-Ratelimit-Reset.

§limit: Option<u32>

Upstream rate-limit bucket capacity from X-Ratelimit-Limit, if present.

§remaining: Option<u32>

Remaining requests in the current window from X-Ratelimit-Remaining, if present.

§

ApiStatus(Box<ApiStatusError>)

Available on crate feature 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>)

Available on crate feature profile only.

Opaque Base64 decoding failure (e.g. malformed textures property or signature).

§

Xml(Box<dyn Error + Send + Sync>)

Available on crate feature loaders only.

Opaque XML parsing failure (e.g. malformed Maven metadata XML).

§

XstsRejected(Box<XstsError>)

Available on crate feature mojang only.

Xbox Live XSTS authorization rejected with an XErr code.

§

MissingUserHash

Available on crate feature mojang only.

Xbox Live / XSTS DisplayClaims omitted the required uhs user hash.

§

DeviceCodeExpired

Available on crate feature mojang only.

Microsoft OAuth2 device code expired before the user completed authorization.

§

DeviceCodeDeclined

Available on crate feature mojang only.

User explicitly declined Microsoft OAuth2 device code authorization.

§

DoesNotOwnMinecraft

Available on crate feature mojang only.

Authenticated Microsoft account does not own Minecraft: Java Edition.

§

MissingTexturesProperty

Available on crate features mojang or yggdrasil only.

Profile properties did not contain a "textures" entry.

§

Yggdrasil(Box<YggdrasilError>)

Available on crate feature yggdrasil only.

Yggdrasil server returned a structured JSON error response.

§

InvalidAliLocation

Available on crate feature yggdrasil only.

X-Authlib-Injector-API-Location header was invalid, circular, or attempted an HTTPS-to-HTTP downgrade.

§

MissingSignature(String)

Available on crate feature yggdrasil-verify only.

Required RSA signature was absent from a profile property.

§

InvalidSignature(String)

Available on crate feature yggdrasil-verify only.

RSA public key PEM or property signature verification failed.

§

BlessingApi

Available on crate feature blessing only.

Blessing Skin API returned a non-zero error code, or code == 0 with a missing expected data payload.

Fields

§code: i32

Numeric status code from the Blessing Skin JSON envelope.

§message: String

Human-readable message from the Blessing Skin JSON envelope.

Implementations§

Source§

impl Error

Source

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.

Source

pub fn api_status_error(&self) -> Option<&ApiStatusError>

Available on crate feature http only.

Returns the structured ApiStatusError payload if this is Error::ApiStatus.

Source

pub fn yggdrasil_error(&self) -> Option<&YggdrasilError>

Available on crate feature yggdrasil only.

Returns the structured YggdrasilError payload if this is Error::Yggdrasil.

Source

pub fn xsts_error(&self) -> Option<&XstsError>

Available on crate feature mojang only.

Returns the structured XstsError payload if this is Error::XstsRejected.

Source

pub fn is_not_found(&self) -> bool

Returns true if this error represents an HTTP 404 Not Found response.

Source

pub fn is_rate_limited(&self) -> bool

Returns true if this error represents an HTTP 429 Too Many Requests response.

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Replaced by Error::source.
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<InvalidHeaderValue> for Error

Source§

fn from(source: InvalidHeaderValue) -> Self

Converts to this type from the input type.
Source§

impl From<ParseError> for Error

Source§

fn from(source: ParseError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Forget for Error

§

impl Freeze for Error

§

impl Move for Error

§

impl Send for Error
where BoxRaw<Inner>: Send, BoxRaw<ErrorImpl>: Send, BoxRaw<ApiStatusError>: Send, RawVecInner: Send, Repr: Send, BoxRaw<dyn Error + Sync + Send>: Send, BoxRaw<XstsError>: Send, BoxRaw<YggdrasilError>: Send,

§

impl Sync for Error
where BoxRaw<Inner>: Sync, BoxRaw<ErrorImpl>: Sync, BoxRaw<ApiStatusError>: Sync, RawVecInner: Sync, Repr: Sync, BoxRaw<dyn Error + Sync + Send>: Sync, BoxRaw<XstsError>: Sync, BoxRaw<YggdrasilError>: Sync,

§

impl Unpin for Error
where Box<Inner>: Unpin, Box<ErrorImpl>: Unpin, Box<ApiStatusError>: Unpin, *const u8 is !null: Unpin, *const () is !null: Unpin, &'static SimpleMessage: Unpin, *const Custom is !null: Unpin, Box<dyn Error + Sync + Send>: Unpin, Box<XstsError>: Unpin, Box<YggdrasilError>: Unpin,

§

impl UnsafeUnpin for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more