Skip to content

Commit 4927c94

Browse files
authored
Merge pull request #97 from RAprogramm/new_verison
New verison
2 parents da2d5c5 + 04484fd commit 4927c94

File tree

12 files changed

+229
-49
lines changed

12 files changed

+229
-49
lines changed

CHANGELOG.md

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

44
## [Unreleased]
55

6+
## [0.11.0] - 2025-10-26
7+
8+
### Changed
9+
- Updated `AppError::database` to accept `Option<Cow<'static, str>>`, allowing
10+
bare `None` calls without type annotations, and added the helper
11+
`AppError::database_with_message` for the common message-bearing path.
12+
13+
### Documentation
14+
- Refreshed the `AppError::database` docs to illustrate the new constructor
15+
behavior and helper usage.
16+
17+
### Tests
18+
- Expanded database constructor tests to cover both the helper and bare `None`
19+
scenario.
20+
21+
## [0.10.9] - 2025-10-26
22+
23+
### Fixed
24+
- Tightened Turnkey rate-limit heuristics to require explicit phrases while
25+
preserving stack-backed searches for short ASCII patterns, preventing matches
26+
on unrelated words such as "corporate".
27+
28+
### Tests
29+
- Added regression coverage to ensure corporate network outages and operational
30+
failure rates classify as network/service issues rather than rate limits.
31+
32+
### Changed
33+
- Raised the documented MSRV to Rust 1.90 to match the `rust-version`
34+
requirement.
35+
36+
### Documentation
37+
- Regenerated the README from the template so installation snippets reflect the
38+
new crate version and MSRV statement.
39+
640
## [0.10.8] - 2025-10-25
741

842
### Fixed

Cargo.lock

Lines changed: 1 addition & 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.10.8"
3+
version = "0.11.0"
44
rust-version = "1.90"
55
edition = "2024"
66
license = "MIT OR Apache-2.0"

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ Stable categories, conservative HTTP mapping, no `unsafe`.
2929

3030
~~~toml
3131
[dependencies]
32-
masterror = { version = "0.10.8", default-features = false }
32+
masterror = { version = "0.11.0", default-features = false }
3333
# or with features:
34-
# masterror = { version = "0.10.8", features = [
34+
# masterror = { version = "0.11.0", features = [
3535
# "axum", "actix", "openapi", "serde_json",
3636
# "sqlx", "sqlx-migrate", "reqwest", "redis",
3737
# "validator", "config", "tokio", "multipart",
@@ -66,10 +66,11 @@ masterror = { version = "0.10.8", default-features = false }
6666
~~~toml
6767
[dependencies]
6868
# lean core
69-
masterror = { version = "0.10.8", default-features = false }
69+
masterror = { version = "0.11.0", default-features = false }
7070

7171
# with Axum/Actix + JSON + integrations
72-
# masterror = { version = "0.10.8", features = [
72+
# masterror = { version = "0.11.0", features = [
73+
7374
# "axum", "actix", "openapi", "serde_json",
7475
# "sqlx", "sqlx-migrate", "reqwest", "redis",
7576
# "validator", "config", "tokio", "multipart",
@@ -378,7 +379,7 @@ diagnostics.
378379

379380
| Specifier | `core::fmt` trait | Example output | Notes |
380381
|------------------|----------------------------|------------------------|-------|
381-
| _default_ | `core::fmt::Display` | `value` | User-facing strings; `#` has no effect. |
382+
| *default* | `core::fmt::Display` | `value` | User-facing strings; `#` has no effect. |
382383
| `:?` / `:#?` | `core::fmt::Debug` | `Struct { .. }` / multi-line | Mirrors `Debug`; `#` pretty-prints structs. |
383384
| `:x` / `:#x` | `core::fmt::LowerHex` | `0x2a` | Hexadecimal; `#` prepends `0x`. |
384385
| `:X` / `:#X` | `core::fmt::UpperHex` | `0x2A` | Uppercase hex; `#` prepends `0x`. |
@@ -578,6 +579,8 @@ assert_eq!(resp.status, 401);
578579

579580
</details>
580581

582+
</details>
583+
581584
<details>
582585
<summary><b>Feature flags</b></summary>
583586

@@ -623,13 +626,13 @@ assert_eq!(resp.status, 401);
623626
Minimal core:
624627

625628
~~~toml
626-
masterror = { version = "0.10.8", default-features = false }
629+
masterror = { version = "0.11.0", default-features = false }
627630
~~~
628631

629632
API (Axum + JSON + deps):
630633

631634
~~~toml
632-
masterror = { version = "0.10.8", features = [
635+
masterror = { version = "0.11.0", features = [
633636
"axum", "serde_json", "openapi",
634637
"sqlx", "reqwest", "redis", "validator", "config", "tokio"
635638
] }
@@ -638,7 +641,7 @@ masterror = { version = "0.10.8", features = [
638641
API (Actix + JSON + deps):
639642

640643
~~~toml
641-
masterror = { version = "0.10.8", features = [
644+
masterror = { version = "0.11.0", features = [
642645
"actix", "serde_json", "openapi",
643646
"sqlx", "reqwest", "redis", "validator", "config", "tokio"
644647
] }
@@ -709,4 +712,3 @@ MSRV = 1.90 (may raise in minor, never in patch).
709712
Apache-2.0 OR MIT, at your option.
710713

711714
</details>
712-

README.template.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,8 @@ assert_eq!(resp.status, 401);
572572

573573
</details>
574574

575+
</details>
576+
575577
<details>
576578
<summary><b>Feature flags</b></summary>
577579

src/app_error/constructors.rs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,39 @@ impl AppError {
5151
}
5252
/// Build a `Database` error with an optional message.
5353
///
54-
/// Accepts `Option` to avoid gratuitous `.map(|...| ...)` at call sites
55-
/// when you may or may not have a safe-to-print string at hand.
56-
pub fn database(msg: Option<impl Into<Cow<'static, str>>>) -> Self {
54+
/// This constructor accepts a pre-built [`Cow`] so callers that already
55+
/// manage ownership can pass either borrowed or owned strings. When you
56+
/// have plain string data, prefer [`AppError::database_with_message`].
57+
///
58+
/// ```rust
59+
/// use masterror::AppError;
60+
///
61+
/// let err = AppError::database(None);
62+
/// assert!(err.message.is_none());
63+
/// ```
64+
pub fn database(msg: Option<Cow<'static, str>>) -> Self {
5765
Self {
5866
kind: AppErrorKind::Database,
59-
message: msg.map(Into::into),
67+
message: msg,
6068
retry: None,
6169
www_authenticate: None
6270
}
6371
}
72+
73+
/// Build a `Database` error with a message.
74+
///
75+
/// Convenience wrapper around [`AppError::database`] for the common case
76+
/// where you start from a plain string-like value.
77+
///
78+
/// ```rust
79+
/// use masterror::AppError;
80+
///
81+
/// let err = AppError::database_with_message("db down");
82+
/// assert_eq!(err.message.as_deref(), Some("db down"));
83+
/// ```
84+
pub fn database_with_message(msg: impl Into<Cow<'static, str>>) -> Self {
85+
Self::database(Some(msg.into()))
86+
}
6487
/// Build a `Config` error.
6588
pub fn config(msg: impl Into<Cow<'static, str>>) -> Self {
6689
Self::with(AppErrorKind::Config, msg)

src/app_error/tests.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::borrow::Cow;
2+
13
use super::{AppResult, core::AppError};
24
use crate::AppErrorKind;
35

@@ -108,10 +110,13 @@ fn constructors_match_kinds() {
108110

109111
#[test]
110112
fn database_accepts_optional_message() {
111-
let with_msg = AppError::database(Some("db down"));
113+
let with_msg = AppError::database_with_message("db down");
112114
assert_err_with_msg(with_msg, AppErrorKind::Database, "db down");
113115

114-
let without = AppError::database(None::<&str>);
116+
let via_option = AppError::database(Some(Cow::Borrowed("db down")));
117+
assert_err_with_msg(via_option, AppErrorKind::Database, "db down");
118+
119+
let without = AppError::database(None);
115120
assert_err_bare(without, AppErrorKind::Database);
116121
}
117122

src/convert/sqlx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl From<SqlxError> for AppError {
5050
fn from(err: SqlxError) -> Self {
5151
match err {
5252
SqlxError::RowNotFound => AppError::not_found("Record not found"),
53-
other => AppError::database(Some(other.to_string()))
53+
other => AppError::database_with_message(other.to_string())
5454
}
5555
}
5656
}
@@ -63,7 +63,7 @@ impl From<SqlxError> for AppError {
6363
#[cfg_attr(docsrs, doc(cfg(feature = "sqlx-migrate")))]
6464
impl From<MigrateError> for AppError {
6565
fn from(err: MigrateError) -> Self {
66-
AppError::database(Some(err.to_string()))
66+
AppError::database_with_message(err.to_string())
6767
}
6868
}
6969

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
//!
2323
//! # Minimum Supported Rust Version (MSRV)
2424
//!
25-
//! MSRV is **1.89**. New minor releases may increase MSRV with a changelog
25+
//! MSRV is **1.90**. New minor releases may increase MSRV with a changelog
2626
//! note, but never in a patch release.
2727
//!
2828
//! # Feature flags

0 commit comments

Comments
 (0)