diff --git a/CHANGELOG.md b/CHANGELOG.md index 1767e62..3a47f16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. ## [Unreleased] + +## [0.3.4] - 2025-09-12 ### Added - `ErrorResponse::with_retry_after_duration` helper for specifying retry advice via `Duration`. - Conversion from `telegram_webapp_sdk::utils::validate_init_data::ValidationError` into `AppError` (feature `telegram-webapp-sdk`). @@ -19,6 +21,7 @@ All notable changes to this project will be documented in this file. - Added Axum test asserting `MultipartError` becomes `AppErrorKind::BadRequest` and preserves the message. - Expanded Actix test to check JSON body and `Retry-After`/`WWW-Authenticate` headers. - Covered fallback classification of unknown messages as `TurnkeyErrorKind::Service`. +- Expanded coverage of `telegram_webapp_sdk` mapping across all `ValidationError` variants. ## [0.3.3] - 2025-09-11 ### Added @@ -96,6 +99,7 @@ All notable changes to this project will be documented in this file. - **MSRV:** 1.89 - **No unsafe:** the crate forbids `unsafe`. +[0.3.4]: https://github.com/RAprogramm/masterror/releases/tag/v0.3.4 [0.3.3]: https://github.com/RAprogramm/masterror/releases/tag/v0.3.3 [0.3.2]: https://github.com/RAprogramm/masterror/releases/tag/v0.3.2 [0.3.1]: https://github.com/RAprogramm/masterror/releases/tag/v0.3.1 diff --git a/Cargo.lock b/Cargo.lock index 9521552..88c3414 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1324,6 +1324,18 @@ checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" [[package]] name = "masterror" version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e7c3a243a6f697e05d0b971c22d0ac029b9080c20b2bbc5f4a3f43ea6024a60" +dependencies = [ + "http 1.3.1", + "serde", + "thiserror", + "tracing", +] + +[[package]] +name = "masterror" +version = "0.3.4" dependencies = [ "actix-web", "axum", @@ -2372,7 +2384,7 @@ dependencies = [ "hex", "hmac-sha256", "js-sys", - "masterror 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "masterror 0.3", "once_cell", "percent-encoding", "serde", diff --git a/Cargo.toml b/Cargo.toml index c5cdf04..ff5a601 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "masterror" -version = "0.3.3" +version = "0.3.4" rust-version = "1.89" edition = "2024" description = "Application error types and response mapping" diff --git a/src/convert/telegram_webapp_sdk.rs b/src/convert/telegram_webapp_sdk.rs index 6c2e0d7..0d85ae8 100644 --- a/src/convert/telegram_webapp_sdk.rs +++ b/src/convert/telegram_webapp_sdk.rs @@ -18,6 +18,9 @@ //! //! ## Example //! +//! ```rust +//! # #[cfg(feature = "telegram-webapp-sdk")] +//! # { //! ```rust,ignore //! use masterror::{AppError, AppErrorKind}; //! use telegram_webapp_sdk::utils::validate_init_data::ValidationError; @@ -28,6 +31,8 @@ //! //! let e = convert(ValidationError::SignatureMismatch); //! assert!(matches!(e.kind, AppErrorKind::TelegramAuth)); +//! assert_eq!(e.message.as_deref(), Some("signature mismatch")); +//! # } //! ``` #[cfg(feature = "telegram-webapp-sdk")] @@ -53,6 +58,21 @@ mod tests { use crate::AppErrorKind; #[test] + fn all_variants_map_to_telegram_auth_and_preserve_message() { + let cases = vec![ + ValidationError::MissingField("hash"), + ValidationError::InvalidEncoding, + ValidationError::InvalidSignatureEncoding, + ValidationError::SignatureMismatch, + ValidationError::InvalidPublicKey, + ]; + + for case in cases { + let msg = case.to_string(); + let app: AppError = case.into(); + assert!(matches!(app.kind, AppErrorKind::TelegramAuth)); + assert_eq!(app.message.as_deref(), Some(msg.as_str())); + } fn validation_error_maps_to_telegram_auth() { let err: AppError = ValidationError::SignatureMismatch.into(); assert!(matches!(err.kind, AppErrorKind::TelegramAuth));