Skip to content

Commit 6e03c5d

Browse files
authored
Merge pull request #24 from RAprogramm/codex/add-error-handling-for-telegram-webapp-sdk
feat: map telegram webapp sdk errors
2 parents e13ad35 + f28662e commit 6e03c5d

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
All notable changes to this project will be documented in this file.
33

44
## [Unreleased]
5+
6+
## [0.3.4] - 2025-09-12
57
### Added
68
- `ErrorResponse::with_retry_after_duration` helper for specifying retry advice via `Duration`.
79
- 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.
1921
- Added Axum test asserting `MultipartError` becomes `AppErrorKind::BadRequest` and preserves the message.
2022
- Expanded Actix test to check JSON body and `Retry-After`/`WWW-Authenticate` headers.
2123
- Covered fallback classification of unknown messages as `TurnkeyErrorKind::Service`.
24+
- Expanded coverage of `telegram_webapp_sdk` mapping across all `ValidationError` variants.
2225

2326
## [0.3.3] - 2025-09-11
2427
### Added
@@ -96,6 +99,7 @@ All notable changes to this project will be documented in this file.
9699
- **MSRV:** 1.89
97100
- **No unsafe:** the crate forbids `unsafe`.
98101

102+
[0.3.4]: https://github.com/RAprogramm/masterror/releases/tag/v0.3.4
99103
[0.3.3]: https://github.com/RAprogramm/masterror/releases/tag/v0.3.3
100104
[0.3.2]: https://github.com/RAprogramm/masterror/releases/tag/v0.3.2
101105
[0.3.1]: https://github.com/RAprogramm/masterror/releases/tag/v0.3.1

Cargo.lock

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "masterror"
3-
version = "0.3.3"
3+
version = "0.3.4"
44
rust-version = "1.89"
55
edition = "2024"
66
description = "Application error types and response mapping"

src/convert/telegram_webapp_sdk.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
//!
1919
//! ## Example
2020
//!
21+
//! ```rust
22+
//! # #[cfg(feature = "telegram-webapp-sdk")]
23+
//! # {
2124
//! ```rust,ignore
2225
//! use masterror::{AppError, AppErrorKind};
2326
//! use telegram_webapp_sdk::utils::validate_init_data::ValidationError;
@@ -28,6 +31,8 @@
2831
//!
2932
//! let e = convert(ValidationError::SignatureMismatch);
3033
//! assert!(matches!(e.kind, AppErrorKind::TelegramAuth));
34+
//! assert_eq!(e.message.as_deref(), Some("signature mismatch"));
35+
//! # }
3136
//! ```
3237
3338
#[cfg(feature = "telegram-webapp-sdk")]
@@ -53,6 +58,21 @@ mod tests {
5358
use crate::AppErrorKind;
5459

5560
#[test]
61+
fn all_variants_map_to_telegram_auth_and_preserve_message() {
62+
let cases = vec![
63+
ValidationError::MissingField("hash"),
64+
ValidationError::InvalidEncoding,
65+
ValidationError::InvalidSignatureEncoding,
66+
ValidationError::SignatureMismatch,
67+
ValidationError::InvalidPublicKey,
68+
];
69+
70+
for case in cases {
71+
let msg = case.to_string();
72+
let app: AppError = case.into();
73+
assert!(matches!(app.kind, AppErrorKind::TelegramAuth));
74+
assert_eq!(app.message.as_deref(), Some(msg.as_str()));
75+
}
5676
fn validation_error_maps_to_telegram_auth() {
5777
let err: AppError = ValidationError::SignatureMismatch.into();
5878
assert!(matches!(err.kind, AppErrorKind::TelegramAuth));

0 commit comments

Comments
 (0)