Skip to main content

nodedb_types/error/
mod.rs

1//! Standardized error types for the NodeDB public API.
2//!
3//! [`NodeDbError`] is a **struct** (not an enum) that separates:
4//! - `code` — stable numeric code for programmatic handling (`NDB-1000`)
5//! - `message` — human-readable explanation
6//! - `details` — machine-matchable [`ErrorDetails`] enum with structured data
7//! - `cause` — optional chained error for debugging
8//!
9//! # Wire format
10//!
11//! Serializes to:
12//! ```json
13//! {
14//!   "code": "NDB-1000",
15//!   "message": "constraint violation on users: duplicate email",
16//!   "details": { "kind": "constraint_violation", "collection": "users" }
17//! }
18//! ```
19//!
20//! # Error code ranges
21//!
22//! | Range       | Category      |
23//! |-------------|---------------|
24//! | 1000–1099   | Write path    |
25//! | 1100–1199   | Read path     |
26//! | 1200–1299   | Query         |
27//! | 2000–2099   | Auth/Security |
28//! | 3000–3099   | Sync          |
29//! | 4000–4099   | Storage       |
30//! | 4100–4199   | WAL           |
31//! | 4200–4299   | Serialization |
32//! | 5000–5099   | Config        |
33//! | 6000–6099   | Cluster       |
34//! | 7000–7099   | Memory        |
35//! | 8000–8099   | Encryption    |
36//! | 9000–9099   | Internal      |
37
38pub mod code;
39pub mod ctors;
40pub mod details;
41pub mod types;
42
43pub use code::ErrorCode;
44pub use details::ErrorDetails;
45pub use types::{NodeDbError, NodeDbResult};