1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! Error types for the nectar-primitives crate
//!
//! This module provides error types and helper functions for handling
//! errors that occur in various components of the crate.
//!
//! ## Error Structure
//!
//! The crate uses a two-level error hierarchy:
//!
//! - `PrimitivesError`: The top-level error type that wraps all other errors
//! - Component-specific errors: More detailed errors from specific subsystems
//! (like `BmtError` and `ChunkError`)
//!
//! ## Example Usage
//!
//! ```
//! use nectar_primitives::error::{PrimitivesError, Result};
//!
//! fn fallible_operation() -> Result<()> {
//! // Something that might fail
//! Ok(())
//! }
//!
//! fn handle_errors() {
//! match fallible_operation() {
//! Ok(_) => println!("Operation succeeded"),
//! Err(e) => match e {
//! PrimitivesError::Bmt(bmt_err) => println!("BMT error: {}", bmt_err),
//! PrimitivesError::Chunk(chunk_err) => println!("Chunk error: {}", chunk_err),
//! _ => println!("Other error: {}", e),
//! }
//! }
//! }
//! ```
//!
//! This design allows for detailed error reporting while maintaining a consistent
//! interface across the crate.
use Error;
/// Result type for operations in the primitives crate
pub type Result<T> = Result;
/// Main error type for the primitives crate
///
/// This enum represents all the possible errors that can occur when using
/// the nectar-primitives crate. It wraps component-specific errors like
/// `BmtError` and `ChunkError` to provide a unified error interface.