Expand description
Ultra-minimal diagnostic code system for the Waddling ecosystem
This crate provides a standardized 4-part diagnostic code format:
Format: SEVERITY.COMPONENT.PRIMARY.SEQUENCE → E.CRYPTO.SALT.001
§Quick Start
use waddling_errors::prelude::*;
// Ergonomic convenience functions
const ERR_SALT: Code = error("CRYPTO", "SALT", 1);
assert_eq!(ERR_SALT.code(), "E.CRYPTO.SALT.001");§Alternative API Styles
use waddling_errors::{Code, Severity};
// Method style
const ERR: Code = Code::error("CRYPTO", "SALT", 1);
// Explicit severity
const WARN: Code = Code::new(Severity::Warning, "CRYPTO", "WEAK", 1);§Sequence Conventions
The Waddling ecosystem uses semantic sequence numbers for common error patterns:
| Sequence | Meaning | Example |
|---|---|---|
| 001 | MISSING | Required item not provided |
| 002 | MISMATCH | Values don’t match expected type/length |
| 003 | INVALID | Format/validation failed |
| 021 | NOTFOUND | Resource not found |
| 025 | CORRUPTED | Data corrupted/integrity check failed |
| 031-897 | (project) | Domain-specific sequences |
| 999 | COMPLETE | Full completion |
Benefits: .001 always means “missing” across ALL Waddling projects,
enabling instant recognition and cross-project consistency.
use waddling_errors::prelude::*;
// Following conventions (recommended)
const ERR_MISSING_SALT: Code = error("CRYPTO", "SALT", 1); // .001 = MISSING
const ERR_LENGTH_MISMATCH: Code = error("CRYPTO", "LENGTH", 2); // .002 = MISMATCH
// Domain-specific (031-897 range for project logic)
const ERR_HMAC_COMPUTE: Code = error("CRYPTO", "HMAC", 31);These conventions are SHOULD guidelines (RFC 2119), not requirements. See repository docs/SEQUENCE-CONVENTIONS.md for complete list and enforcement strategies.
§Error Registry Pattern
For larger projects, create a central registry:
// errors.rs - Your project's error registry
pub mod errors {
use waddling_errors::prelude::*;
// Crypto errors (E.CRYPTO.*)
pub const SALT_MISSING: Code = error("CRYPTO", "SALT", 1);
pub const KEY_LENGTH: Code = error("CRYPTO", "LENGTH", 2);
pub const HMAC_INVALID: Code = error("CRYPTO", "HMAC", 3);
// Parser warnings (W.PARSE.*)
pub const DEPRECATED_SYNTAX: Code = warning("PARSE", "DEPR", 1);
}Modules§
- prelude
- Prelude module for convenient imports
Structs§
- Code
- Waddling diagnostic code:
SEVERITY.COMPONENT.PRIMARY.SEQUENCE
Enums§
- Severity
- Diagnostic message severity level (single-character prefix for 4-part codes)
Functions§
- blocked
- Create a blocked code (B)
- completed
- Create a completed code (K)
- critical
- Create a critical code (C)
- error
- Create an error code (E)
- info
- Create an info code (I)
- success
- Create a success code (S)
- trace
- Create a trace code (T)
- warning
- Create a warning code (W)
Type Aliases§
- Diagnostic
Code - Backward compatibility alias for
Code - Error
Code - Backward compatibility alias for
Code