Skip to main content

Error

Type Alias Error 

Source
pub type Error = CoreError;
Expand description

🚨 OpenLark 客户端错误类型

直接类型别名,充分利用 CoreError 的强大功能

Aliased Type§

pub enum Error {
    Network(Box<NetworkError>),
    Authentication {
        message: String,
        code: ErrorCode,
        ctx: Box<ErrorContext>,
    },
    Api(Box<ApiError>),
    Validation {
        field: Cow<'static, str>,
        message: String,
        code: ErrorCode,
        ctx: Box<ErrorContext>,
    },
    Configuration {
        message: String,
        code: ErrorCode,
        ctx: Box<ErrorContext>,
    },
    Serialization {
        message: String,
        source: Option<Box<dyn Error + Send + Sync>>,
        code: ErrorCode,
        ctx: Box<ErrorContext>,
    },
    Business {
        code: ErrorCode,
        message: String,
        ctx: Box<ErrorContext>,
    },
    Timeout {
        duration: Duration,
        operation: Option<String>,
        ctx: Box<ErrorContext>,
    },
    RateLimit {
        limit: u32,
        window: Duration,
        reset_after: Option<Duration>,
        code: ErrorCode,
        ctx: Box<ErrorContext>,
    },
    ServiceUnavailable {
        service: Cow<'static, str>,
        retry_after: Option<Duration>,
        code: ErrorCode,
        ctx: Box<ErrorContext>,
    },
    Internal {
        code: ErrorCode,
        message: String,
        source: Option<Box<dyn Error + Send + Sync>>,
        ctx: Box<ErrorContext>,
    },
}

Variants§

§

Network(Box<NetworkError>)

网络错误

§

Authentication

认证错误

Fields

§message: String

错误消息

§code: ErrorCode

错误码

§ctx: Box<ErrorContext>

错误上下文

§

Api(Box<ApiError>)

API 错误

§

Validation

验证错误

Fields

§field: Cow<'static, str>

字段名

§message: String

错误消息

§code: ErrorCode

错误码

§ctx: Box<ErrorContext>

错误上下文

§

Configuration

配置错误

Fields

§message: String

错误消息

§code: ErrorCode

错误码

§ctx: Box<ErrorContext>

错误上下文

§

Serialization

序列化错误

Fields

§message: String

错误消息

§source: Option<Box<dyn Error + Send + Sync>>

源错误

§code: ErrorCode

错误码

§ctx: Box<ErrorContext>

错误上下文

§

Business

业务错误

Fields

§code: ErrorCode

错误码

§message: String

错误消息

§ctx: Box<ErrorContext>

错误上下文

§

Timeout

超时错误

Fields

§duration: Duration

超时时长

§operation: Option<String>

操作名

§ctx: Box<ErrorContext>

错误上下文

§

RateLimit

限流错误

Fields

§limit: u32

限制次数

§window: Duration

时间窗口

§reset_after: Option<Duration>

重置时间

§code: ErrorCode

错误码

§ctx: Box<ErrorContext>

错误上下文

§

ServiceUnavailable

服务不可用错误

Fields

§service: Cow<'static, str>

服务名

§retry_after: Option<Duration>

重试等待时间

§code: ErrorCode

错误码

§ctx: Box<ErrorContext>

错误上下文

§

Internal

内部错误

Fields

§code: ErrorCode

错误码

§message: String

错误消息

§source: Option<Box<dyn Error + Send + Sync>>

源错误

§ctx: Box<ErrorContext>

错误上下文