Skip to main content

Module error

Module error 

Source
Expand description

§Error and Result Helpers

Provides shared boxed error helpers and result aliases used by generic callbacks, integration glue, and source error storage.

This module intentionally contains only type-erased error helpers. Concrete domain errors remain in their owning crates.

Use these helpers when the exact error type is deliberately unimportant or cannot be expressed conveniently, for example callback return types, generic defaults, and stored source errors. Prefer concrete error enums or structs for public APIs where callers need structured recovery.

§Examples

use qubit_error::error::{BoxError, BoxResult, IntoBoxError};

fn parse_port(text: &str) -> BoxResult<u16> {
    text.parse::<u16>()
        .map_err(|error| error.into_box_error())
}

let port = parse_port("8080").expect("valid port should parse");
assert_eq!(port, 8080);

let error: BoxError = parse_port("bad").expect_err("invalid port should fail");
assert!(error.to_string().contains("invalid digit"));

§Author

Haixing Hu

Traits§

IntoBoxError
Extension trait for converting concrete errors into BoxError.

Type Aliases§

BoxError
Boxed dynamic error used when a concrete error type is intentionally erased.
BoxResult
Result alias using BoxError as the error type.
DynError
Dynamic error trait object used by shared boxed error helpers.