Comprehensive real-world examples demonstrating masterror integration with popular frameworks and use cases.
| Example | Description | Run Command |
|---|---|---|
basic_usage.rs |
Core error creation and conversion patterns | cargo run --example basic_usage |
derive_error.rs |
Custom error types with derive macro | cargo run --example derive_error |
structured_metadata.rs |
Attaching JSON metadata and context | cargo run --example structured_metadata |
colored_cli.rs |
Terminal output with color support | cargo run --example colored_cli |
redaction.rs |
Sensitive data redaction | cargo run --example redaction |
migrate_from_anyhow.rs |
Migration guide from anyhow | cargo run --example migrate_from_anyhow |
migrate_from_thiserror.rs |
Migration guide from thiserror | cargo run --example migrate_from_thiserror |
| Example | Description | Status |
|---|---|---|
axum-rest-api/ |
REST API with RFC 7807 Problem Details | ✅ Available |
sqlx-database/ |
Database error handling with SQLx | ✅ Available |
custom-domain-errors/ |
Payment processing domain errors | ✅ Available |
basic-async/ |
Async error handling with tokio | ✅ Available |
multi-transport/ |
Shared errors across HTTP + gRPC | 🚧 Planned |
tonic-grpc-service/ |
gRPC service with tonic | 🚧 Planned |
actix-web-service/ |
Actix-web integration | 🚧 Planned |
telemetry-integration/ |
OpenTelemetry + tracing | 🚧 Planned |
comparison-thiserror/ |
Side-by-side comparison | 🚧 Planned |
cargo run --example basic_usage
cargo run --example colored_cliEach service example is a workspace member with its own Cargo.toml:
cd examples/axum-rest-api
cargo run
cd examples/sqlx-database
cargo testEach real-world example includes:
- Runnable code - Full working service or application
- README.md - Scenario explanation and usage guide
- Tests - Integration and unit tests
- Comments - Key decisions and patterns explained
- Minimal dependencies - Only necessary crates
When adding new examples:
- Follow project structure conventions
- Add SPDX headers to all files
- Include comprehensive tests
- Update this README.md index
- Ensure
cargo testpasses - Add example to CI workflow
All examples are licensed under MIT, same as masterror.