Skip to main content

nodedb_types/error/
mod.rs

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