Skip to main content

Module error

Module error 

Source
Expand description

错误处理模块

定义应用程序错误类型和结果类型别名。

§错误类型

提供多种错误变体,涵盖初始化、配置、HTTP 请求、缓存等场景。

§示例

use crates_docs::error::{Error, Result};

fn may_fail() -> Result<String> {
    // 可能失败的操作
    Ok("success".to_string())
}

// 创建结构化错误
fn create_config_error() -> Error {
    Error::config("field_name", "invalid value")
}

fn create_cache_error() -> Error {
    Error::cache("set", Some("key".to_string()), "operation failed")
}

Enums§

Error
应用程序错误类型

Type Aliases§

Result
结果类型别名