Error

Enum Error 

Source
pub enum Error {
Show 27 variants MalformedBody { error_type: MalformedBodyErrorType, message: String, }, MissingBody { message: String, }, InvalidField { field: String, message: String, }, MissingField { field: String, message: String, }, MalformedIp { message: String, }, NotFound { entity: String, message: String, }, GuildOnly { message: String, }, UnsupportedAuthMethod { message: String, }, InvalidToken { message: String, }, InvalidCredentials { what: String, message: String, }, InvalidCaptcha { message: String, }, NotMember { guild_id: u64, message: String, }, NotOwner { guild_id: u64, message: String, }, NotBotOwner { bot_id: u64, message: String, }, NotMessageAuthor { message_id: u64, message: String, }, RoleTooLow { guild_id: u64, top_role_id: u64, top_role_position: u16, desired_position: u16, message: String, }, MissingPermissions { guild_id: u64, permissions: Permissions, message: String, }, RoleIsManaged { guild_id: u64, role_id: u64, message: String, }, CannotLeaveAsOwner { id: u64, message: String, }, CannotActOnSelf { message: String, }, CannotFriendBots { target_id: u64, message: String, }, UserInteractionDisallowed { interaction_type: UserInteractionType, target_id: u64, message: String, }, BlockedByUser { target_id: u64, message: String, }, AlreadyTaken { what: String, message: String, }, AlreadyExists { what: String, message: String, }, Ratelimited { retry_after: f32, ip: String, message: String, }, InternalError { what: Option<String>, message: String, debug: Option<String>, },
}
Expand description

An error that occurs within Adapt.

Variants§

§

MalformedBody

Received a malformed JSON or MsgPack body.

Fields

§error_type: MalformedBodyErrorType

Extra information about the error.

§message: String

A generalized message about the error.

§

MissingBody

You are missing the request body in an endpoint that requires it. This is commonly JSON or MsgPack.

Fields

§message: String

The error message.

§

InvalidField

Invalid field in the request body.

Fields

§field: String

The field that failed validation.

§message: String

The error message.

§

MissingField

You are missing a required field in the request body.

Fields

§field: String

The name of the missing field.

§message: String

The error message.

§

MalformedIp

Could not resolve a plausible IP address from the request.

Fields

§message: String

The error message.

§

NotFound

The entity was not found.

Fields

§entity: String

The type of item that couldn’t be found.

§message: String

The error message.

§

GuildOnly

This operation is only allowed in guilds.

Fields

§message: String

The error message.

§

UnsupportedAuthMethod

Tried authorizing a bot account with anything but an authentication token.

Fields

§message: String

The error message.

§

InvalidToken

The request required a valid authentication token, but one of the following happened:

  • The token was not provided.
  • The token was malformed, i.e. a non-UTF-8 string.
  • The token does not exist or is invalid.

Fields

§message: String

The error message.

§

InvalidCredentials

Invalid login credentials were provided, i.e. an invalid password.

Fields

§what: String

Which credential was invalid.

§message: String

The error message.

§

InvalidCaptcha

Invalid Turnstile CAPTCHA token was provided. This is a token provided by Cloudflare when a user completes a CAPTCHA, and is used while registering new users to prevent spam.

Fields

§message: String

The error message.

§

NotMember

You must be a member of the guild to perform the requested action.

Fields

§guild_id: u64

The ID of the guild you are not a member of.

§message: String

The error message.

§

NotOwner

You must be the owner of the guild to perform the requested action.

Fields

§guild_id: u64

The ID of the guild you are not the owner of.

§message: String

The error message.

§

NotBotOwner

You must be the owner of the bot to perform the requested action.

Fields

§bot_id: u64

The ID of the bot you are not the owner of.

§message: String

The error message.

§

NotMessageAuthor

You are not the author of the message you are trying to edit.

Fields

§message_id: u64

The ID of the message you are trying to edit.

§message: String

The error message.

§

RoleTooLow

You are too low in the role hierarchy to perform the requested action.

Fields

§guild_id: u64

The ID of the guild you are not the owner of.

§top_role_id: u64

The ID of your top role. This is the role you possess with the highest position.

§top_role_position: u16

The position of your top role.

§desired_position: u16

The desired position your top role should be in the role hierarchy.

§message: String

The error message.

§

MissingPermissions

You are missing the required permissions to perform the requested action.

Fields

§guild_id: u64

The ID of the guild you are missing permissions in.

§permissions: Permissions

The permissions required to perform the requested action.

§message: String

The error message.

§

RoleIsManaged

You are trying to delete a managed role.

Fields

§guild_id: u64

The ID of the guild the role is in.

§role_id: u64

The ID of the role that is managed.

§message: String

The error message.

§

CannotLeaveAsOwner

You cannot leave a server or group DM that you are the owner of (you should transfer ownership before leaving).

Fields

§id: u64

The ID of the guild or group DM you are trying to leave.

§message: String

The error message.

§

CannotActOnSelf

You cannot perform the requested action on yourself.

Fields

§message: String

The error message.

§

CannotFriendBots

You cannot add bots as friends.

Fields

§target_id: u64

The ID of the bot you are trying to friend.

§message: String

The error message.

§

UserInteractionDisallowed

The user you are trying to interact with (e.g. add as a friend, open DMs, etc.) has privacy settings that prevent you from doing so.

Fields

§interaction_type: UserInteractionType

The type of interaction that was disallowed.

§target_id: u64

The ID of the user you are attempting to interact with.

§message: String

The error message.

§

BlockedByUser

The user has blocked you, so you cannot interact with them.

Fields

§target_id: u64

The ID of the user that blocked you.

§message: String

The error message.

§

AlreadyTaken

Something was already taken, e.g. a username or email.

Fields

§what: String

What was already taken.

§message: String

The error message.

§

AlreadyExists

Something already exists, e.g. a relationship.

Fields

§what: String

What already exists.

§message: String

The error message.

§

Ratelimited

You are sending requests too quickly are you are being rate limited.

Fields

§retry_after: f32

How long you should wait before sending another request, in whole seconds.

§ip: String

The IP address that is being rate limited.

§message: String

The ratelimited message.

§

InternalError

Internal server error occured, this is likely a bug.

Fields

§what: Option<String>

What caused the error. None if unknown.

§message: String

The error message.

§debug: Option<String>

A debug version of the error, or None if there is no debug version.

Implementations§

Source§

impl Error

Source

pub const fn http_status_code(&self) -> Option<u16>

The HTTP status code associated with this error. If this error is not sent over HTTP, this will be None.

Source

pub fn custom(message: impl AsRef<str>) -> Self

Returns an internal error with the given message.

Source

pub fn custom_for(what: impl AsRef<str>, message: impl AsRef<str>) -> Self

Returns an internal error with the given “what” and message.

Trait Implementations§

Source§

impl Clone for Error

Source§

fn clone(&self) -> Error

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Error

Source§

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

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

impl Serialize for Error

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnwindSafe 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.