Skip to main content

qubit_error/error/
mod.rs

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