Skip to main content

ErrorCode

Enum ErrorCode 

Source
pub enum ErrorCode {
Show 79 variants Success = 0, BadRequest = 400, Unauthorized = 401, Forbidden = 403, NotFound = 404, MethodNotAllowed = 405, Conflict = 409, TooManyRequests = 429, InternalServerError = 500, BadGateway = 502, ServiceUnavailable = 503, GatewayTimeout = 504, AppTicketInvalid = 10_012, AppStatusException = 10_013, AppPermissionDenied = 19_001, AccessTokenInvalid = 99_991_671, AccessTokenFormatInvalid = 99_991_661, AppAccessTokenInvalid = 99_991_664, TenantAccessTokenInvalid = 99_991_663, SsoTokenInvalid = 99_991_670, PermissionMissing = 99_991_672, AccessTokenNoPermission = 99_991_676, AccessTokenExpiredV2 = 99_991_677, UserSessionInvalid = 99_991_641, UserSessionNotFound = 99_991_642, UserSessionTimeout = 99_991_645, UserIdentityInvalid = 99_991_669, UserTypeNotSupportedV2 = 99_991_674, UserIdentityMismatch = 99_991_675, UserIdInvalid = 99_992_351, OpenIdInvalid = 99_992_352, UnionIdInvalid = 99_992_353, AppNotInstalled = 10_003, UserNotFound = 60_001, UserStatusException = 60_002, DepartmentNotFound = 60_003, ChatNotFound = 70_001, ChatTypeNotSupported = 70_002, MessageNotFound = 80_001, MessageTypeNotSupported = 80_002, FileNotFound = 90_001, FileSizeExceeded = 90_002, FileTypeNotSupported = 90_003, CalendarNotFound = 110_001, EventNotFound = 110_002, EventConflict = 110_003, DocumentNotFound = 120_001, DocumentPermissionDenied = 120_002, DocumentLocked = 120_003, SheetNotFound = 120_011, TableNotFound = 120_021, NetworkTimeout = 999_001, NetworkConnectionFailed = 999_002, DnsResolutionFailed = 999_003, SslCertificateError = 999_004, ConnectionRefused = 999_005, SerializationError = 999_010, DataFormatError = 999_011, EncodingError = 999_012, AuthenticationFailed = 999_020, PermissionDenied = 999_021, TokenExpired = 999_022, InvalidSignature = 999_023, ValidationError = 999_030, MissingRequiredParameter = 999_031, InvalidParameterFormat = 999_032, ParameterOutOfRange = 999_033, BusinessError = 999_040, OperationNotSupported = 999_041, ResourceConflict = 999_042, InternalError = 999_050, ConfigurationError = 999_051, ResourceExhausted = 999_052, RateLimitExceeded = 999_060, CacheMiss = 999_070, CacheServiceUnavailable = 999_071, SecurityPolicyViolation = 999_080, AccessDenied = 999_081, Unknown = 999_999,
}
Expand description

标准错误码枚举

涵盖所有可能的标准错误情况,包括HTTP状态码、飞书API错误码、 网络错误码、系统错误码等。

Variants§

§

Success = 0

成功

§

BadRequest = 400

请求参数错误

§

Unauthorized = 401

未认证

§

Forbidden = 403

禁止访问

§

NotFound = 404

资源不存在

§

MethodNotAllowed = 405

方法不允许

§

Conflict = 409

请求冲突

§

TooManyRequests = 429

请求频率过高

§

InternalServerError = 500

内部服务器错误

§

BadGateway = 502

网关错误

§

ServiceUnavailable = 503

服务不可用

§

GatewayTimeout = 504

网关超时

§

AppTicketInvalid = 10_012

应用票据无效

§

AppStatusException = 10_013

应用状态异常

§

AppPermissionDenied = 19_001

应用权限不足

§

AccessTokenInvalid = 99_991_671

访问令牌无效

§

AccessTokenFormatInvalid = 99_991_661

访问令牌格式错误/无效

§

AppAccessTokenInvalid = 99_991_664

应用访问令牌无效

§

TenantAccessTokenInvalid = 99_991_663

租户访问令牌无效

§

SsoTokenInvalid = 99_991_670

SSO 访问令牌无效

§

PermissionMissing = 99_991_672

缺少所需权限

§

AccessTokenNoPermission = 99_991_676

访问令牌缺少权限

§

AccessTokenExpiredV2 = 99_991_677

访问令牌已过期(飞书通用码)

§

UserSessionInvalid = 99_991_641

用户会话已失效

§

UserSessionNotFound = 99_991_642

用户会话不存在

§

UserSessionTimeout = 99_991_645

用户会话超时

§

UserIdentityInvalid = 99_991_669

用户身份解析失败

§

UserTypeNotSupportedV2 = 99_991_674

用户类型不支持

§

UserIdentityMismatch = 99_991_675

用户身份不匹配

§

UserIdInvalid = 99_992_351

用户ID非法

§

OpenIdInvalid = 99_992_352

OpenID 非法

§

UnionIdInvalid = 99_992_353

UnionID 非法

§

AppNotInstalled = 10_003

应用未安装

§

UserNotFound = 60_001

用户不存在

§

UserStatusException = 60_002

用户状态异常

§

DepartmentNotFound = 60_003

部门不存在

§

ChatNotFound = 70_001

群组不存在

§

ChatTypeNotSupported = 70_002

群组类型不支持

§

MessageNotFound = 80_001

消息不存在

§

MessageTypeNotSupported = 80_002

消息类型不支持

§

FileNotFound = 90_001

文件不存在

§

FileSizeExceeded = 90_002

文件大小超限

§

FileTypeNotSupported = 90_003

文件类型不支持

§

CalendarNotFound = 110_001

日历不存在

§

EventNotFound = 110_002

日程不存在

§

EventConflict = 110_003

日程冲突

§

DocumentNotFound = 120_001

文档不存在

§

DocumentPermissionDenied = 120_002

文档权限不足

§

DocumentLocked = 120_003

文档已锁定

§

SheetNotFound = 120_011

工作表不存在

§

TableNotFound = 120_021

表格不存在

§

NetworkTimeout = 999_001

网络连接超时

§

NetworkConnectionFailed = 999_002

网络连接失败

§

DnsResolutionFailed = 999_003

DNS解析失败

§

SslCertificateError = 999_004

SSL证书错误

§

ConnectionRefused = 999_005

连接被拒绝

§

SerializationError = 999_010

JSON解析错误

§

DataFormatError = 999_011

数据格式错误

§

EncodingError = 999_012

编码错误

§

AuthenticationFailed = 999_020

身份验证失败

§

PermissionDenied = 999_021

权限被拒绝

§

TokenExpired = 999_022

令牌已过期

§

InvalidSignature = 999_023

无效签名

§

ValidationError = 999_030

参数验证失败

§

MissingRequiredParameter = 999_031

缺少必需参数

§

InvalidParameterFormat = 999_032

参数格式错误

§

ParameterOutOfRange = 999_033

参数值超出范围

§

BusinessError = 999_040

业务逻辑错误

§

OperationNotSupported = 999_041

操作不被支持

§

ResourceConflict = 999_042

资源状态冲突

§

InternalError = 999_050

系统内部错误

§

ConfigurationError = 999_051

配置错误

§

ResourceExhausted = 999_052

资源耗尽

§

RateLimitExceeded = 999_060

请求频率限制

§

CacheMiss = 999_070

缓存未命中

§

CacheServiceUnavailable = 999_071

缓存服务不可用

§

SecurityPolicyViolation = 999_080

安全策略违规

§

AccessDenied = 999_081

访问被拒绝

§

Unknown = 999_999

未知错误

Implementations§

Source§

impl ErrorCode

Source

pub fn from_code(code: i32) -> Self

从数值创建错误码

Source

pub fn as_code(&self) -> i32

获取数值形式

Source

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

获取错误码的描述

Source

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

获取详细的错误说明

Source

pub fn is_success(&self) -> bool

判断是否为成功状态

Source

pub fn is_client_error(&self) -> bool

判断是否为客户端错误 (4xx)

Source

pub fn is_server_error(&self) -> bool

判断是否为服务器错误 (5xx)

Source

pub fn is_network_error(&self) -> bool

判断是否为网络相关错误

Source

pub fn is_auth_error(&self) -> bool

判断是否为认证相关错误

Source

pub fn is_permission_error(&self) -> bool

判断是否为权限相关错误

Source

pub fn is_retryable(&self) -> bool

判断是否为可重试错误

Source

pub fn suggested_retry_delay(&self) -> Option<u64>

获取建议的重试延迟时间(秒)

Source

pub fn http_status(&self) -> Option<u16>

获取HTTP状态码

Source

pub fn from_http_status(status: u16) -> Self

从HTTP状态码创建错误码

Source

pub fn from_feishu_code(code: i32) -> Option<Self>

按飞书通用错误码映射(仅飞书返回体的 code 字段,未知返回 None)

Source

pub fn for_error_type(error_type: &str) -> Self

根据错误类型自动选择合适的错误码

为CoreError枚举变体提供最佳的错误码匹配

Source

pub fn network() -> Self

创建网络相关错误码

Source

pub fn authentication() -> Self

创建认证相关错误码

Source

pub fn permission() -> Self

创建权限相关错误码

Source

pub fn validation() -> Self

创建验证相关错误码

Source

pub fn configuration() -> Self

创建配置相关错误码

Source

pub fn internal() -> Self

创建系统内部错误码

Source

pub fn serialization() -> Self

创建序列化错误码

Source

pub fn unknown() -> Self

创建未知错误码

Source

pub fn from_message(message: &str) -> Self

从字符串描述智能推断错误码

根据错误消息的关键词自动推断最合适的错误码

Source

pub fn should_retry(&self, attempt: u32) -> bool

判断是否应该触发重试策略

提供更细粒度的重试判断逻辑

Source

pub fn exponential_backoff_delay(&self, attempt: u32) -> Option<u64>

获取重试的指数退避延迟时间(毫秒)

提供智能的退避策略

Source

pub fn severity(&self) -> ErrorSeverity

获取错误的严重程度

Source

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

获取用户友好的恢复建议

Source

pub fn is_user_error(&self) -> bool

判断是否为用户操作导致的错误

Source

pub fn is_system_error(&self) -> bool

判断是否为系统问题导致的错误

Source

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

获取日志级别建议

Source§

impl ErrorCode

Source

pub fn category(&self) -> ErrorCategory

获取错误码分类

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<'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 From<ErrorCode> for ErrorType

从 ErrorCode 转换到 ErrorType

Source§

fn from(code: ErrorCode) -> Self

Converts to this type from the input type.
Source§

impl Hash for ErrorCode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. 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> 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: 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: 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> 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> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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

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