pub enum ErrorCode {
Show 80 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,
ResponseTooLarge = 41_300,
CacheMiss = 999_070,
CacheServiceUnavailable = 999_071,
SecurityPolicyViolation = 999_080,
AccessDenied = 999_081,
Unknown = 999_999,
}Expand description
标准错误码枚举
涵盖所有可能的标准错误情况,包括HTTP状态码、飞书API错误码、 网络错误码、系统错误码等。
Variants§
Success = 0
成功
BadRequest = 400
请求参数错误
未认证
Forbidden = 403
禁止访问
NotFound = 404
资源不存在
MethodNotAllowed = 405
方法不允许
Conflict = 409
请求冲突
TooManyRequests = 429
请求频率过高
InternalServerError = 500
内部服务器错误
BadGateway = 502
网关错误
服务不可用
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
请求频率限制
ResponseTooLarge = 41_300
响应体大小超过限制
CacheMiss = 999_070
缓存未命中
缓存服务不可用
SecurityPolicyViolation = 999_080
安全策略违规
AccessDenied = 999_081
访问被拒绝
Unknown = 999_999
未知错误
Implementations§
Source§impl ErrorCode
impl ErrorCode
Sourcepub fn description(&self) -> &'static str
pub fn description(&self) -> &'static str
获取错误码的描述
Sourcepub fn detailed_description(&self) -> &'static str
pub fn detailed_description(&self) -> &'static str
获取详细的错误说明
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
判断是否为成功状态
Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
判断是否为客户端错误 (4xx)
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
判断是否为服务器错误 (5xx)
Sourcepub fn is_network_error(&self) -> bool
pub fn is_network_error(&self) -> bool
判断是否为网络相关错误
Sourcepub fn is_auth_error(&self) -> bool
pub fn is_auth_error(&self) -> bool
判断是否为认证相关错误
Sourcepub fn is_permission_error(&self) -> bool
pub fn is_permission_error(&self) -> bool
判断是否为权限相关错误
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
判断是否为可重试错误
Sourcepub fn suggested_retry_delay(&self) -> Option<u64>
pub fn suggested_retry_delay(&self) -> Option<u64>
获取建议的重试延迟时间(秒)
Sourcepub fn http_status(&self) -> Option<u16>
pub fn http_status(&self) -> Option<u16>
获取HTTP状态码
Sourcepub fn from_http_status(status: u16) -> ErrorCode
pub fn from_http_status(status: u16) -> ErrorCode
从HTTP状态码创建错误码
Sourcepub fn from_feishu_code(code: i32) -> Option<ErrorCode>
pub fn from_feishu_code(code: i32) -> Option<ErrorCode>
按飞书通用错误码映射(仅飞书返回体的 code 字段,未知返回 None)
Sourcepub fn for_error_type(error_type: &str) -> ErrorCode
pub fn for_error_type(error_type: &str) -> ErrorCode
根据错误类型自动选择合适的错误码
为CoreError枚举变体提供最佳的错误码匹配
Sourcepub fn authentication() -> ErrorCode
pub fn authentication() -> ErrorCode
创建认证相关错误码
Sourcepub fn permission() -> ErrorCode
pub fn permission() -> ErrorCode
创建权限相关错误码
Sourcepub fn validation() -> ErrorCode
pub fn validation() -> ErrorCode
创建验证相关错误码
Sourcepub fn configuration() -> ErrorCode
pub fn configuration() -> ErrorCode
创建配置相关错误码
Sourcepub fn serialization() -> ErrorCode
pub fn serialization() -> ErrorCode
创建序列化错误码
Sourcepub fn from_message(message: &str) -> ErrorCode
pub fn from_message(message: &str) -> ErrorCode
从字符串描述智能推断错误码
根据错误消息的关键词自动推断最合适的错误码
Sourcepub fn should_retry(&self, attempt: u32) -> bool
pub fn should_retry(&self, attempt: u32) -> bool
判断是否应该触发重试策略
提供更细粒度的重试判断逻辑
Sourcepub fn exponential_backoff_delay(&self, attempt: u32) -> Option<u64>
pub fn exponential_backoff_delay(&self, attempt: u32) -> Option<u64>
获取重试的指数退避延迟时间(毫秒)
提供智能的退避策略
Sourcepub fn severity(&self) -> ErrorSeverity
pub fn severity(&self) -> ErrorSeverity
获取错误的严重程度
Sourcepub fn recovery_suggestion(&self) -> &'static str
pub fn recovery_suggestion(&self) -> &'static str
获取用户友好的恢复建议
Sourcepub fn is_user_error(&self) -> bool
pub fn is_user_error(&self) -> bool
判断是否为用户操作导致的错误
Sourcepub fn is_system_error(&self) -> bool
pub fn is_system_error(&self) -> bool
判断是否为系统问题导致的错误