errors

package
v0.2.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package errors defines the structured error codes returned in all Uncord API error responses. Both the server and any future clients import this package as the single source of truth, preventing code drift.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code string

Code is a machine-readable error identifier included in every API error response. Clients should match on Code rather than on HTTP status codes or human-readable messages.

const (

	// Unauthorised indicates the request lacks valid authentication.
	Unauthorised Code = "UNAUTHORISED"
	// TokenExpired indicates the access token has expired.
	TokenExpired Code = "TOKEN_EXPIRED"
	// TokenReused indicates a refresh token was presented after it had
	// already been consumed, which may signal token theft.
	TokenReused Code = "TOKEN_REUSED"
	// InvalidCredentials indicates incorrect email or password.
	InvalidCredentials Code = "INVALID_CREDENTIALS"
	// InvalidToken indicates a verification or refresh token is invalid or expired.
	InvalidToken Code = "INVALID_TOKEN"
	// MFARequired indicates the account requires multi-factor authentication.
	MFARequired Code = "MFA_REQUIRED"
	// InvalidMFACode indicates the provided MFA code is incorrect.
	InvalidMFACode Code = "INVALID_MFA_CODE"
	// MFANotEnabled indicates MFA is not enabled on the account.
	MFANotEnabled Code = "MFA_NOT_ENABLED"
	// MFAAlreadyEnabled indicates MFA is already enabled on the account.
	MFAAlreadyEnabled Code = "MFA_ALREADY_ENABLED"
	// MissingPermissions indicates the user lacks a required permission.
	MissingPermissions Code = "MISSING_PERMISSIONS"
	// OwnerOnly indicates the action is restricted to the server owner.
	OwnerOnly Code = "OWNER_ONLY"
	// RoleHierarchy indicates the action is blocked by role hierarchy rules.
	RoleHierarchy Code = "ROLE_HIERARCHY"
	// Banned indicates the user is banned from the server.
	Banned Code = "BANNED"
	// UserTimedOut indicates the user is currently timed out.
	UserTimedOut Code = "USER_TIMED_OUT"
	// AccountDeleted indicates registration is blocked because the email or username was previously used by a deleted
	// account.
	AccountDeleted Code = "ACCOUNT_DELETED"
	// ServerOwner indicates the server owner must transfer ownership before performing this action.
	ServerOwner Code = "SERVER_OWNER"
	// CSRFTokenMissing indicates the CSRF token cookie or header is absent from a state-changing request.
	CSRFTokenMissing Code = "CSRF_TOKEN_MISSING"
	// CSRFTokenInvalid indicates the CSRF token header does not match the CSRF token cookie.
	CSRFTokenInvalid Code = "CSRF_TOKEN_INVALID"
	// EmailNotVerified indicates the user must verify their email address before accessing the server.
	EmailNotVerified Code = "EMAIL_NOT_VERIFIED"
	// EmailAlreadyVerified indicates the user's email is already verified.
	EmailAlreadyVerified Code = "EMAIL_ALREADY_VERIFIED"
	// MembershipRequired indicates the user must complete server onboarding before performing this action.
	MembershipRequired Code = "MEMBERSHIP_REQUIRED"
	// OpenJoinDisabled indicates open server joining is not enabled.
	OpenJoinDisabled Code = "OPEN_JOIN_DISABLED"

	// InvalidBody indicates the request body could not be parsed.
	InvalidBody Code = "INVALID_BODY"
	// InvalidEmail indicates the email address is malformed.
	InvalidEmail Code = "INVALID_EMAIL"
	// InvalidUsername indicates the username does not meet requirements.
	InvalidUsername Code = "INVALID_USERNAME"
	// InvalidPassword indicates the password does not meet requirements.
	InvalidPassword Code = "INVALID_PASSWORD"
	// DisposableEmail indicates disposable email addresses are not allowed.
	DisposableEmail Code = "DISPOSABLE_EMAIL"
	// ValidationError indicates a generic input validation failure.
	ValidationError Code = "VALIDATION_ERROR"
	// PayloadTooLarge indicates the request body exceeds the size limit.
	PayloadTooLarge Code = "PAYLOAD_TOO_LARGE"
	// UnsupportedContentType indicates the uploaded file type is not allowed.
	UnsupportedContentType Code = "UNSUPPORTED_CONTENT_TYPE"
	// ImageDimensionsExceeded indicates the image exceeds dimension limits.
	ImageDimensionsExceeded Code = "IMAGE_DIMENSIONS_EXCEEDED"
	// InvalidEmojiName indicates the emoji name is invalid.
	InvalidEmojiName Code = "INVALID_EMOJI_NAME"
	// MissingChannelID indicates the required channel ID parameter is absent.
	MissingChannelID Code = "MISSING_CHANNEL_ID"
	// InvalidChannelID indicates the channel ID parameter is malformed.
	InvalidChannelID Code = "INVALID_CHANNEL_ID"
	// InvalidMessageID indicates the message ID parameter is malformed.
	InvalidMessageID Code = "INVALID_MESSAGE_ID"
	// InvalidThreadID indicates the thread ID parameter is malformed.
	InvalidThreadID Code = "INVALID_THREAD_ID"

	// NotFound indicates the requested resource does not exist.
	NotFound Code = "NOT_FOUND"
	// UnknownUser indicates the referenced user does not exist.
	UnknownUser Code = "UNKNOWN_USER"
	// UnknownChannel indicates the referenced channel does not exist.
	UnknownChannel Code = "UNKNOWN_CHANNEL"
	// UnknownRole indicates the referenced role does not exist.
	UnknownRole Code = "UNKNOWN_ROLE"
	// UnknownMessage indicates the referenced message does not exist.
	UnknownMessage Code = "UNKNOWN_MESSAGE"
	// UnknownInvite indicates the referenced invite does not exist.
	UnknownInvite Code = "UNKNOWN_INVITE"
	// UnknownCategory indicates the referenced category does not exist.
	UnknownCategory Code = "UNKNOWN_CATEGORY"
	// UnknownOverride indicates the referenced permission override does not exist.
	UnknownOverride Code = "UNKNOWN_OVERRIDE"
	// UnknownMember indicates the referenced member does not exist.
	UnknownMember Code = "UNKNOWN_MEMBER"
	// UnknownBan indicates the referenced ban does not exist.
	UnknownBan Code = "UNKNOWN_BAN"
	// UnknownThread indicates the referenced thread does not exist.
	UnknownThread Code = "UNKNOWN_THREAD"
	// UnknownAttachment indicates one or more referenced attachment IDs do not exist or are not available for linking.
	UnknownAttachment Code = "UNKNOWN_ATTACHMENT"
	// UnknownEmoji indicates the referenced custom emoji does not exist.
	UnknownEmoji Code = "UNKNOWN_EMOJI"
	// ReactionNotFound indicates the reaction to be removed does not exist.
	ReactionNotFound Code = "REACTION_NOT_FOUND"

	// KeyBundleIncomplete indicates the target user has no registered devices or no device has a complete key bundle.
	KeyBundleIncomplete Code = "KEY_BUNDLE_INCOMPLETE"
	// InvalidKeyMaterial indicates the supplied key material has an invalid length or encoding.
	InvalidKeyMaterial Code = "INVALID_KEY_MATERIAL"
	// OPKBatchTooLarge indicates the one-time pre-key upload batch exceeds the maximum allowed size.
	OPKBatchTooLarge Code = "OPK_BATCH_TOO_LARGE"
	// DuplicateKeyID indicates a key with the same ID already exists for this device.
	DuplicateKeyID Code = "DUPLICATE_KEY_ID"
	// UnknownDevice indicates the referenced device does not exist.
	UnknownDevice Code = "UNKNOWN_DEVICE"
	// MaxDevicesReached indicates the user has reached the maximum number of registered devices.
	MaxDevicesReached Code = "MAX_DEVICES_REACHED"

	// UnknownDMChannel indicates the referenced DM channel does not exist.
	UnknownDMChannel Code = "UNKNOWN_DM_CHANNEL"
	// NotParticipant indicates the user is not a participant of the DM channel.
	NotParticipant Code = "NOT_PARTICIPANT"
	// AlreadyParticipant indicates the user is already a participant of the DM channel.
	AlreadyParticipant Code = "ALREADY_PARTICIPANT"
	// GroupDMFull indicates the group DM has reached its maximum number of participants.
	GroupDMFull Code = "GROUP_DM_FULL"
	// NotDMOwner indicates the action is restricted to the group DM owner.
	NotDMOwner Code = "NOT_DM_OWNER"

	// MaxChannelsReached indicates the server has reached the maximum number of channels.
	MaxChannelsReached Code = "MAX_CHANNELS_REACHED"
	// MaxCategoriesReached indicates the server has reached the maximum number of categories.
	MaxCategoriesReached Code = "MAX_CATEGORIES_REACHED"
	// MaxRolesReached indicates the server has reached the maximum number of roles.
	MaxRolesReached Code = "MAX_ROLES_REACHED"
	// MaxEmojiReached indicates the server has reached the maximum number of custom emoji.
	MaxEmojiReached Code = "MAX_EMOJI_REACHED"

	// AlreadyExists indicates the resource already exists (e.g. duplicate email).
	AlreadyExists Code = "ALREADY_EXISTS"
	// AlreadyMember indicates the user is already a server member.
	AlreadyMember Code = "ALREADY_MEMBER"
	// EmojiNameTaken indicates the chosen emoji name is already in use.
	EmojiNameTaken Code = "EMOJI_NAME_TAKEN"
	// AlreadyReacted indicates the user has already reacted with this emoji on this message.
	AlreadyReacted Code = "ALREADY_REACTED"
	// AlreadyPinned indicates the message is already pinned.
	AlreadyPinned Code = "ALREADY_PINNED"
	// NotPinned indicates the message is not currently pinned.
	NotPinned Code = "NOT_PINNED"
	// ThreadExists indicates the message already has a thread attached.
	ThreadExists Code = "THREAD_EXISTS"
	// ThreadArchived indicates the thread is archived and does not accept new messages.
	ThreadArchived Code = "THREAD_ARCHIVED"
	// ThreadLocked indicates the thread is locked and does not accept new messages or metadata changes.
	ThreadLocked Code = "THREAD_LOCKED"

	// SyncedSettingsNotFound indicates the user has not stored synced settings on this server.
	SyncedSettingsNotFound Code = "SYNCED_SETTINGS_NOT_FOUND"
	// SyncedSettingsVersionConflict indicates the provided blob version is not higher than the current stored version.
	SyncedSettingsVersionConflict Code = "SYNCED_SETTINGS_VERSION_CONFLICT"

	// RateLimited indicates the client has exceeded the request rate limit.
	RateLimited Code = "RATE_LIMITED"

	// InternalError indicates an unexpected server-side failure.
	InternalError Code = "INTERNAL_ERROR"
	// SearchUnavailable indicates the search backend is temporarily unavailable.
	SearchUnavailable Code = "SEARCH_UNAVAILABLE"
	// ServiceUnavailable indicates the service is temporarily unavailable.
	ServiceUnavailable Code = "SERVICE_UNAVAILABLE"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL