From 65f898191879d9ca63a622494bc25e33ff0498d4 Mon Sep 17 00:00:00 2001 From: RA <70325462+RAprogramm@users.noreply.github.com> Date: Sun, 21 Sep 2025 06:11:21 +0700 Subject: [PATCH] Add masterror-derive README and bump versions --- CHANGELOG.md | 13 +++++++ Cargo.lock | 4 +-- Cargo.toml | 4 +-- README.md | 14 ++++---- masterror-derive/Cargo.toml | 2 +- masterror-derive/README.md | 68 +++++++++++++++++++++++++++++++++++++ 6 files changed, 93 insertions(+), 12 deletions(-) create mode 100644 masterror-derive/README.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 286bbe9..4b9d410 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +## [0.10.6] - 2025-09-21 + +### Fixed +- Added a crate-local README for `masterror-derive` so `cargo publish` passes + when crates.io validates the `readme` manifest key. + +### Changed +- Bumped `masterror-derive` to `0.6.2` to capture the packaging fix. + +### Documentation +- Documented the derive macros and supported attributes in + `masterror-derive/README.md` for crates.io readers. + ## [0.10.5] - 2025-09-20 ### Added diff --git a/Cargo.lock b/Cargo.lock index f9dc7cb..20c236e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1606,7 +1606,7 @@ dependencies = [ [[package]] name = "masterror" -version = "0.10.5" +version = "0.10.6" dependencies = [ "actix-web", "axum", @@ -1636,7 +1636,7 @@ dependencies = [ [[package]] name = "masterror-derive" -version = "0.6.1" +version = "0.6.2" dependencies = [ "masterror-template", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 32b82e1..509485f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "masterror" -version = "0.10.5" +version = "0.10.6" rust-version = "1.90" edition = "2024" license = "MIT OR Apache-2.0" @@ -71,7 +71,7 @@ turnkey = [] openapi = ["dep:utoipa"] [workspace.dependencies] -masterror-derive = { version = "0.6.1" } +masterror-derive = { version = "0.6.2" } masterror-template = { version = "0.3.1" } [dependencies] diff --git a/README.md b/README.md index 02da5d2..eb6568f 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,9 @@ Stable categories, conservative HTTP mapping, no `unsafe`. ~~~toml [dependencies] -masterror = { version = "0.10.5", default-features = false } +masterror = { version = "0.10.6", default-features = false } # or with features: -# masterror = { version = "0.10.5", features = [ +# masterror = { version = "0.10.6", features = [ # "axum", "actix", "openapi", "serde_json", # "sqlx", "sqlx-migrate", "reqwest", "redis", # "validator", "config", "tokio", "multipart", @@ -66,10 +66,10 @@ masterror = { version = "0.10.5", default-features = false } ~~~toml [dependencies] # lean core -masterror = { version = "0.10.5", default-features = false } +masterror = { version = "0.10.6", default-features = false } # with Axum/Actix + JSON + integrations -# masterror = { version = "0.10.5", features = [ +# masterror = { version = "0.10.6", features = [ # "axum", "actix", "openapi", "serde_json", # "sqlx", "sqlx-migrate", "reqwest", "redis", # "validator", "config", "tokio", "multipart", @@ -623,13 +623,13 @@ assert_eq!(resp.status, 401); Minimal core: ~~~toml -masterror = { version = "0.10.5", default-features = false } +masterror = { version = "0.10.6", default-features = false } ~~~ API (Axum + JSON + deps): ~~~toml -masterror = { version = "0.10.5", features = [ +masterror = { version = "0.10.6", features = [ "axum", "serde_json", "openapi", "sqlx", "reqwest", "redis", "validator", "config", "tokio" ] } @@ -638,7 +638,7 @@ masterror = { version = "0.10.5", features = [ API (Actix + JSON + deps): ~~~toml -masterror = { version = "0.10.5", features = [ +masterror = { version = "0.10.6", features = [ "actix", "serde_json", "openapi", "sqlx", "reqwest", "redis", "validator", "config", "tokio" ] } diff --git a/masterror-derive/Cargo.toml b/masterror-derive/Cargo.toml index d764ec5..3e23e98 100644 --- a/masterror-derive/Cargo.toml +++ b/masterror-derive/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "masterror-derive" rust-version = "1.90" -version = "0.6.1" +version = "0.6.2" edition = "2024" license = "MIT OR Apache-2.0" repository = "https://github.com/RAprogramm/masterror" diff --git a/masterror-derive/README.md b/masterror-derive/README.md new file mode 100644 index 0000000..9848d2a --- /dev/null +++ b/masterror-derive/README.md @@ -0,0 +1,68 @@ +# masterror-derive + +Procedural macros that power [`masterror`](https://crates.io/crates/masterror)'s +`#[derive(Error)]`. The derive generates ergonomic `std::error::Error` and +`Display` implementations together with seamless integration into +`masterror`'s domain-centric `AppError` type. + +> **Tip:** Depend on the `masterror` crate in application code and import the +> macros from there (`use masterror::Error;`). This standalone crate is +> published to make `cargo install`/`cargo package` flows happy and to support +> advanced macro integrations. + +## Quick start + +```toml +[dependencies] +masterror = "0.10" +``` + +```rust +use masterror::{AppError, Error}; + +#[derive(Error)] +#[error(display = "failed to parse payload: {source}")] +#[app_error(kind = "BadRequest")] +pub struct PayloadInvalid { + #[source] + pub source: serde_json::Error, +} + +fn parse(input: &str) -> Result<(), AppError> { + serde_json::from_str::(input) + .map(|_| ()) + .map_err(PayloadInvalid::from) +} +``` + +The derive implements `Display`, `std::error::Error`, and conversion glue so +you can return rich `AppError` values with a single `?`. + +## Supported attributes + +- `#[error(display = ...)]` – formats the error message using captured fields. +- `#[source]` / `#[from]` – wires source error propagation and conversion. +- `#[backtrace]` – exposes an optional captured `Backtrace`. +- `#[app_error(...)]` – configures how the error maps into `AppError` + (kind, HTTP status, telemetry). +- `#[provide(...)]` – attaches structured telemetry providers that surface + typed context (IDs, domains, tenant information) through tracing layers. + +See the main [`masterror` README](https://github.com/RAprogramm/masterror/blob/HEAD/README.md) for an end-to-end guide and +advanced examples covering templated display strings, telemetry providers and +OpenAPI/schema integrations. + +## License + +Licensed under either of + +- Apache License, Version 2.0, ([LICENSE-APACHE](https://github.com/RAprogramm/masterror/blob/HEAD/LICENSE-APACHE) or + ) +- MIT license ([LICENSE-MIT](https://github.com/RAprogramm/masterror/blob/HEAD/LICENSE-MIT) or ) + +at your option. + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be +licensed as above, without any additional terms or conditions. +