waddling-errors đĻ
Type-safe diagnostic code system
Overview
waddling-errors provides structured diagnostic codes with a consistent 4-part format: SEVERITY.COMPONENT.PRIMARY.SEQUENCE
E.AUTH.TOKEN.001 // Error in Auth component, Token category, sequence 001
W.PARSER.SYNTAX.003 // Warning in Parser component, Syntax category, sequence 003
S.BUILD.DONE.999 // Success in Build component, Done category, sequence 999
Key Features
- â Type-safe - Define your own component/primary enums with compile-time checking
- â Zero dependencies by default - Modular features (doc-gen, hash, serde, emoji, ansi-colors)
- â
Semantic methods -
is_blocking(),is_positive(),priority()for intelligent error handling - â Documentation generation - Auto-generate JSON & interactive HTML with role-based filtering
- â Hash codes - Optional 5-character base62 hashes for compact logging
- â
no_stdcompatible - Works in embedded and WASM environments
Installation
[]
# Minimal
= "0.4"
# With features
= { = "0.4", = ["doc-gen", "hash", "serde"] }
Available features: doc-gen, hash, metadata, ansi-colors, emoji, serde, std
Quick Start
use *;
// 1. Define your error structure
// 2. Create error codes
const ERR_TOKEN_MISSING: = error;
const ERR_SYNTAX_INVALID: = error;
const SUCCESS_CONNECTED: = success;
// 3. Use them
Severity Levels
Nine severity levels with semantic methods:
| Severity | Code | Emoji | Priority | Blocking | Use Case |
|---|---|---|---|---|---|
| Error | E |
â | 8 | Yes | Invalid input, logic errors |
| Blocked | B |
đĢ | 7 | Yes | Deadlock, I/O wait, network down |
| Critical | C |
đĨ | 6 | No | Data corruption, resource exhaustion |
| Warning | W |
â ī¸ | 5 | No | Deprecated API, edge cases |
| Help | H |
đĄ | 4 | No | Helpful suggestions, tips |
| Success | S |
â | 3 | No | Operation succeeded |
| Completed | K |
âī¸ | 2 | No | Task/phase finished |
| Info | I |
âšī¸ | 1 | No | Events, milestones, status |
| Trace | T |
đ | 0 | No | Execution traces, probes, timing |
let severity = Error;
// Semantic methods
severity.is_blocking; // true - stops execution
severity.is_negative; // true - indicates failure
severity.is_positive; // false
severity.priority; // 8 (0-8 scale)
// Visual representation (requires features)
severity.emoji; // "â"
severity.ansi_color; // "\x1b[1;31m" (bold red)
Error Registry Pattern
Organize errors in a central registry:
// errors.rs
// Use across your project
use ;
Documentation Generation
Generate searchable HTML documentation with role-based filtering:
Error Browser with Search:

Interactive Query Builder:

use DocGenerator;
use Role;
let mut gen = new;
// Register components, primaries, sequences for rich context
gen.register_component;
gen.register_primary;
gen.register_sequence;
// Register error codes
gen.register_code_extended;
// Generate documentation
gen.generate_json?;
gen.generate_html_for_role?;
gen.generate_html_for_role?;
Three documentation roles:
Role::Public- End-user facing errorsRole::Developer- For contributorsRole::Internal- Full team visibility
JSON-Only Workflow (Custom Frontends)
For teams preferring their own frontend stack, use JSON-only output:
// Generate only JSON data
doc_gen.generate_json?;
// Use with React/Vue/Svelte/etc
// Your frontend fetches errors.json and builds custom UI
Trade-offs:
- â Full UI control - Use modern frameworks, hot reload, TypeScript
- â Requires build tooling - Node.js, npm, bundler
- â Distribution complexity - Need HTTP server (file:// has CORS issues)
Default HTML generation:
- â Zero dependencies - No Node.js or build tools needed
- â Single-file distribution - Double-click to open, share via email
- â Offline-first - Works in air-gapped environments
Sequence Conventions
Semantic sequence numbers provide consistency:
| Sequence | Meaning | Example |
|---|---|---|
| 001 | MISSING | Required item not provided |
| 002 | MISMATCH | Values don't match expected type |
| 003 | INVALID | Format/validation failed |
| 007 | DUPLICATE | Rate limit or duplicate entry |
| 008 | DENIED | Permission/access denied |
| 021 | NOTFOUND | Resource not found |
| 025 | CORRUPTED | Data corruption detected |
| 999 | COMPLETE | Full completion |
See docs/SEQUENCE-CONVENTIONS.md for the complete list.
Hash Codes
Enable 5-character base62 hashes for compact logging:
// Cargo.toml
waddling-errors =
const ERR: = error;
println!;
// E.AUTH.TOKEN.001 â #a7Kx2
// Use in logs
error!;
// Search logs: grep "#a7Kx2" app.log
Examples
Basic usage:
With documentation metadata:
Production pattern (6 components, 31 errors, role-based docs):
WASM/no_std:
Documentation
- API Documentation - Full API reference
- CHANGELOG.md - Version history
- docs/FEATURE_FLAGS.md - Feature guide
- docs/SEQUENCE-CONVENTIONS.md - Sequence semantics
License
Dual-licensed under MIT or Apache-2.0.