Skip to content

Conversation

@RAprogramm
Copy link
Owner

Summary

Created comprehensive examples directory with 4 real-world service examples demonstrating masterror integration with popular frameworks.

Changes

New Directory Structure

  • examples/README.md - Index of all examples with running instructions

  • examples/axum-rest-api/ - REST API with RFC 7807 Problem Details

    • Full CRUD operations for user management
    • Domain-specific error types (UserError)
    • 11 integration tests using axum-test
    • Metadata attachment and structured errors
  • examples/sqlx-database/ - Database error handling with SQLx

    • Connection error handling
    • Constraint violations (unique, foreign key)
    • Transaction patterns
    • Row not found handling
  • examples/custom-domain-errors/ - Payment processing domain errors

    • Payment, Auth, Validation, External Service error types
    • Derive macro usage (#[derive(Error)])
    • Error conversion to AppError
  • examples/basic-async/ - Async error handling with tokio

    • Timeout error conversion
    • Error propagation through async call chains
    • AppResult usage

Key Features

  • All examples have publish = false to prevent crates.io publication
  • SPDX license headers in all files
  • Comprehensive README.md for each example
  • Full integration tests for axum-rest-api example
  • Updated main README.template.md with Examples section

Test Coverage

  • axum-rest-api: 11 integration tests covering all endpoints and error scenarios
  • All examples compile and run without warnings
  • All workspace tests pass

Verification

  • cargo build -p axum-rest-api - Success
  • cargo test -p axum-rest-api --tests - 11 tests passed
  • cargo run -p <example> - All examples run successfully
  • cargo +nightly fmt --all - All code formatted
  • cargo test --workspace --lib - All tests pass
  • reuse lint - Full compliance (247/247 files)

Closes #211

…mples

Created examples/ directory with real-world service examples demonstrating
masterror integration with popular frameworks:

- axum-rest-api: Full REST API with RFC 7807 Problem Details, domain errors,
  metadata attachment, and 11 integration tests
- sqlx-database: Database error handling patterns including connection errors,
  constraint violations, and transactions
- custom-domain-errors: Payment processing domain with derive macro usage,
  showcasing authentication, validation, and external service errors
- basic-async: Async error handling with tokio, timeout conversion, and
  error propagation patterns

All examples include:
- Comprehensive README.md documentation
- Runnable source code with cargo run
- Integration tests where applicable
- SPDX license headers
- publish = false in Cargo.toml

Updated:
- examples/README.md: Index of all examples with running instructions
- README.template.md: Added Examples section with table
- README.md: Regenerated from template
- Cargo.toml: Added 4 examples as workspace members

Closes #211
Added cargo deny check to pre-commit hook to catch license issues locally
before CI. This prevents CI failures like the Unicode-3.0 license issue.

Changes:
- Added cargo deny check (advisories, bans, licenses, sources) to pre-commit
- Created .github/scripts/pre-commit (version-controlled hook)
- Created .github/scripts/install-hooks.sh (automated installation)
- Updated deny.toml to allow OSI-approved licenses:
  - Unicode-3.0 (ICU dependencies)
  - BSD-3-Clause (encoding_rs, matchit)
  - Zlib (foldhash)

Pre-commit now runs all CI checks locally:
- rustfmt (nightly)
- REUSE compliance
- clippy (all features, all targets)
- tests (all features)
- cargo audit
- cargo deny (NEW) - catches license issues before CI
- README.md generation

This significantly reduces CI failures by catching issues locally.
@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@RAprogramm RAprogramm merged commit c4b4a0a into main Oct 24, 2025
32 of 33 checks passed
@RAprogramm RAprogramm deleted the 211 branch October 24, 2025 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create examples directory with real-world scenarios

2 participants