Skip to main content

ErrorCode

Enum ErrorCode 

Source
#[repr(u32)]
pub enum ErrorCode {
Show 100 variants Ok = 0, SystemError = 1, SystemBusy = 2, ServiceUnavailable = 3, InternalError = 4, Timeout = 5, Maintenance = 6, DatabaseError = 7, CacheError = 8, NetworkError = 9, ProtocolError = 100, UnsupportedProtocol = 101, InvalidPacket = 102, PacketTooLarge = 103, EncodingError = 104, DecodingError = 105, VersionError = 200, ClientVersionTooOld = 201, ClientVersionTooNew = 202, IncompatibleVersion = 203, DeprecatedApi = 204, AuthRequired = 10_000, InvalidToken = 10_001, TokenExpired = 10_002, TokenRevoked = 10_003, PermissionDenied = 10_004, SessionExpired = 10_005, SessionNotFound = 10_006, UserBanned = 10_007, IpNotAllowed = 10_008, InvalidParams = 10_100, MissingRequiredParam = 10_101, InvalidParamType = 10_102, ParamOutOfRange = 10_103, InvalidFormat = 10_104, InvalidJson = 10_105, PayloadTooLarge = 10_106, OperationNotAllowed = 10_200, ResourceNotFound = 10_201, ResourceAlreadyExists = 10_202, ResourceDeleted = 10_203, DuplicateOperation = 10_204, OperationConflict = 10_205, RateLimitExceeded = 10_300, DailyQuotaExceeded = 10_301, MonthlyQuotaExceeded = 10_302, ConcurrentLimitExceeded = 10_303, MessageNotFound = 20_000, MessageDeleted = 20_001, MessageRevoked = 20_002, MessageSendFailed = 20_003, MessageTooLarge = 20_004, MessageTypeInvalid = 20_005, MessageContentInvalid = 20_006, MessageCannotRevoke = 20_007, MessageAlreadyRead = 20_008, SendMessageTooFast = 20_009, OfflineMessageFull = 20_100, OfflineMessageExpired = 20_101, UserNotFound = 20_200, UserAlreadyExists = 20_201, UserDeleted = 20_202, UserBannedAlt = 20_203, UserNotActive = 20_204, NicknameInvalid = 20_205, AvatarInvalid = 20_206, GroupNotFound = 20_300, GroupDeleted = 20_301, GroupFull = 20_302, NotGroupMember = 20_303, NotGroupAdmin = 20_304, NotGroupOwner = 20_305, GroupMuted = 20_306, MemberMuted = 20_307, MemberAlreadyInGroup = 20_308, CannotRemoveOwner = 20_309, JoinApprovalRequired = 20_310, FriendNotFound = 20_400, AlreadyFriends = 20_401, BlockedByUser = 20_402, UserInBlacklist = 20_403, FriendRequestExpired = 20_404, ChannelNotFound = 20_500, ChannelDeleted = 20_501, ChannelMuted = 20_502, FileNotFound = 20_600, FileUploadFailed = 20_601, FileTooLarge = 20_602, FileTypeNotAllowed = 20_603, UploadTokenInvalid = 20_604, UploadTokenExpired = 20_605, StorageQuotaExceeded = 20_606, QRCodeNotFound = 20_700, QRCodeExpired = 20_701, QRCodeUsed = 20_702, QRCodeRevoked = 20_703, QRCodeLimitExceeded = 20_704, DeviceNotFound = 20_800, DeviceLimitExceeded = 20_801, DeviceNotVerified = 20_802,
}
Expand description

PrivChat IM Error Code v3.0

Error code design (priority-based):

  • 0: Success
  • 1-999: System errors (protocol, version, runtime stability) ⭐ First priority
  • 10000-19999: Common errors (authentication, parameters, permissions, rate limiting)
  • 20000-65535: Business errors (freely defined, allocated as needed)

Design principles: Simple and practical, flexible extension, within 65535 (u16 range)

Important: Error codes cannot be changed once published. New error codes must use new values.

Variants§

§

Ok = 0

Operation successful

§

SystemError = 1

System error

§

SystemBusy = 2

System busy, please retry later

§

ServiceUnavailable = 3

Service unavailable

§

InternalError = 4

Internal error

§

Timeout = 5

Operation timeout

§

Maintenance = 6

System maintenance

§

DatabaseError = 7

Database error

§

CacheError = 8

Cache error

§

NetworkError = 9

Network error

§

ProtocolError = 100

Protocol error

§

UnsupportedProtocol = 101

Unsupported protocol version

§

InvalidPacket = 102

Invalid packet

§

PacketTooLarge = 103

Packet too large

§

EncodingError = 104

Encoding error

§

DecodingError = 105

Decoding error

§

VersionError = 200

Version error

§

ClientVersionTooOld = 201

Client version too old

§

ClientVersionTooNew = 202

Client version too new

§

IncompatibleVersion = 203

Incompatible version

§

DeprecatedApi = 204

API deprecated

§

AuthRequired = 10_000

Authentication required

§

InvalidToken = 10_001

Invalid token

§

TokenExpired = 10_002

Token expired

§

TokenRevoked = 10_003

Token revoked

§

PermissionDenied = 10_004

Permission denied

§

SessionExpired = 10_005

Session expired

§

SessionNotFound = 10_006

Session not found

§

UserBanned = 10_007

User banned

§

IpNotAllowed = 10_008

IP address not allowed

§

InvalidParams = 10_100

Invalid parameters

§

MissingRequiredParam = 10_101

Missing required parameter

§

InvalidParamType = 10_102

Invalid parameter type

§

ParamOutOfRange = 10_103

Parameter out of range

§

InvalidFormat = 10_104

Invalid format

§

InvalidJson = 10_105

Invalid JSON format

§

PayloadTooLarge = 10_106

Payload too large

§

OperationNotAllowed = 10_200

Operation not allowed

§

ResourceNotFound = 10_201

Resource not found

§

ResourceAlreadyExists = 10_202

Resource already exists

§

ResourceDeleted = 10_203

Resource deleted

§

DuplicateOperation = 10_204

Duplicate operation

§

OperationConflict = 10_205

Operation conflict

§

RateLimitExceeded = 10_300

Rate limit exceeded

§

DailyQuotaExceeded = 10_301

Daily quota exceeded

§

MonthlyQuotaExceeded = 10_302

Monthly quota exceeded

§

ConcurrentLimitExceeded = 10_303

Concurrent limit exceeded

§

MessageNotFound = 20_000

Message not found

§

MessageDeleted = 20_001

Message deleted

§

MessageRevoked = 20_002

Message revoked

§

MessageSendFailed = 20_003

Message send failed

§

MessageTooLarge = 20_004

Message too large

§

MessageTypeInvalid = 20_005

Invalid message type

§

MessageContentInvalid = 20_006

Invalid message content

§

MessageCannotRevoke = 20_007

Message cannot be revoked (timeout)

§

MessageAlreadyRead = 20_008

Message already read

§

SendMessageTooFast = 20_009

Send message too fast

§

OfflineMessageFull = 20_100

Offline message queue full

§

OfflineMessageExpired = 20_101

Offline message expired

§

UserNotFound = 20_200

User not found

§

UserAlreadyExists = 20_201

User already exists

§

UserDeleted = 20_202

User deleted

§

UserBannedAlt = 20_203

User banned

§

UserNotActive = 20_204

User not active

§

NicknameInvalid = 20_205

Invalid nickname

§

AvatarInvalid = 20_206

Invalid avatar

§

GroupNotFound = 20_300

Group not found

§

GroupDeleted = 20_301

Group deleted

§

GroupFull = 20_302

Group full

§

NotGroupMember = 20_303

Not a group member

§

NotGroupAdmin = 20_304

Not a group admin

§

NotGroupOwner = 20_305

Not a group owner

§

GroupMuted = 20_306

Group muted

§

MemberMuted = 20_307

Member muted

§

MemberAlreadyInGroup = 20_308

Member already in group

§

CannotRemoveOwner = 20_309

Cannot remove owner

§

JoinApprovalRequired = 20_310

Join approval required

§

FriendNotFound = 20_400

Friend not found

§

AlreadyFriends = 20_401

Already friends

§

BlockedByUser = 20_402

Blocked by user

§

UserInBlacklist = 20_403

User in blacklist

§

FriendRequestExpired = 20_404

Friend request expired

§

ChannelNotFound = 20_500

Channel not found

§

ChannelDeleted = 20_501

Channel deleted

§

ChannelMuted = 20_502

Channel muted

§

FileNotFound = 20_600

File not found

§

FileUploadFailed = 20_601

File upload failed

§

FileTooLarge = 20_602

File too large

§

FileTypeNotAllowed = 20_603

File type not allowed

§

UploadTokenInvalid = 20_604

Upload token invalid

§

UploadTokenExpired = 20_605

Upload token expired

§

StorageQuotaExceeded = 20_606

Storage quota exceeded

§

QRCodeNotFound = 20_700

QR code not found

§

QRCodeExpired = 20_701

QR code expired

§

QRCodeUsed = 20_702

QR code used

§

QRCodeRevoked = 20_703

QR code revoked

§

QRCodeLimitExceeded = 20_704

QR code limit exceeded

§

DeviceNotFound = 20_800

Device not found

§

DeviceLimitExceeded = 20_801

Device limit exceeded

§

DeviceNotVerified = 20_802

Device not verified

Implementations§

Source§

impl ErrorCode

Source

pub fn code(&self) -> u32

Get the error code value

Source

pub fn message(&self) -> &'static str

Get the error code message

Source

pub fn from_code(code: u32) -> Option<Self>

Convert from u32 to ErrorCode

Source

pub fn is_system_error(&self) -> bool

Check if this is a system error (first priority)

Source

pub fn is_common_error(&self) -> bool

Check if this is a common error

Source

pub fn is_business_error(&self) -> bool

Check if this is a business error

Trait Implementations§

Source§

impl Clone for ErrorCode

Source§

fn clone(&self) -> ErrorCode

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 ErrorCode

Source§

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

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

impl Default for ErrorCode

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ErrorCode

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ErrorCode

Source§

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

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

impl PartialEq for ErrorCode

Source§

fn eq(&self, other: &ErrorCode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ErrorCode

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
Source§

impl Copy for ErrorCode

Source§

impl Eq for ErrorCode

Source§

impl StructuralPartialEq for ErrorCode

Auto Trait Implementations§

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> 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 = 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,