Skip to main content

qubit_error/lang/error/
mod.rs

1/*******************************************************************************
2 *
3 *    Copyright (c) 2025 - 2026.
4 *    Haixing Hu, Qubit Co. Ltd.
5 *
6 *    All rights reserved.
7 *
8 ******************************************************************************/
9//! # Error and Result Helpers
10//!
11//! Provides shared boxed error helpers and result aliases used by generic
12//! callbacks, integration glue, and source error storage.
13//!
14//! This module intentionally contains only type-erased error helpers. Concrete
15//! domain errors remain in their owning crates.
16//!
17//! Use these helpers when the exact error type is deliberately unimportant or
18//! cannot be expressed conveniently, for example callback return types, generic
19//! defaults, and stored source errors. Prefer concrete error enums or structs
20//! for public APIs where callers need structured recovery.
21//!
22//! # Examples
23//!
24//! ```rust
25//! use qubit_error::error::{BoxError, BoxResult, IntoBoxError};
26//!
27//! fn parse_port(text: &str) -> BoxResult<u16> {
28//!     text.parse::<u16>()
29//!         .map_err(|error| error.into_box_error())
30//! }
31//!
32//! let port = parse_port("8080").expect("valid port should parse");
33//! assert_eq!(port, 8080);
34//!
35//! let error: BoxError = parse_port("bad").expect_err("invalid port should fail");
36//! assert!(error.to_string().contains("invalid digit"));
37//! ```
38//!
39//! # Author
40//!
41//! Haixing Hu
42
43mod box_error;
44mod box_result;
45mod dyn_error;
46mod into_box_error;
47
48pub use box_error::BoxError;
49pub use box_result::BoxResult;
50pub use dyn_error::DynError;
51pub use into_box_error::IntoBoxError;