Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [0.11.2] - 2025-10-28

### Changed
- Surfaced the [`AppErrorKind`] display text as the fallback `ErrorResponse`
message so clients receive semantic descriptions without providing a custom
message.

### Tests
- Added regression coverage ensuring bare `AppError` kinds map to their
corresponding default message.

## [0.11.1] - 2025-10-27

### Documentation
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "masterror"
version = "0.11.1"
version = "0.11.2"
rust-version = "1.90"
edition = "2024"
license = "MIT OR Apache-2.0"
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ guides, comparisons with `thiserror`/`anyhow`, and troubleshooting recipes.

~~~toml
[dependencies]
masterror = { version = "0.11.1", default-features = false }
masterror = { version = "0.11.2", default-features = false }
# or with features:
# masterror = { version = "0.11.1", features = [
# masterror = { version = "0.11.2", features = [
# "axum", "actix", "openapi", "serde_json",
# "sqlx", "sqlx-migrate", "reqwest", "redis",
# "validator", "config", "tokio", "multipart",
Expand Down Expand Up @@ -73,10 +73,10 @@ masterror = { version = "0.11.1", default-features = false }
~~~toml
[dependencies]
# lean core
masterror = { version = "0.11.1", default-features = false }
masterror = { version = "0.11.2", default-features = false }

# with Axum/Actix + JSON + integrations
# masterror = { version = "0.11.1", features = [
# masterror = { version = "0.11.2", features = [
# "axum", "actix", "openapi", "serde_json",
# "sqlx", "sqlx-migrate", "reqwest", "redis",
# "validator", "config", "tokio", "multipart",
Expand Down Expand Up @@ -632,13 +632,13 @@ assert_eq!(resp.status, 401);
Minimal core:

~~~toml
masterror = { version = "0.11.1", default-features = false }
masterror = { version = "0.11.2", default-features = false }
~~~

API (Axum + JSON + deps):

~~~toml
masterror = { version = "0.11.1", features = [
masterror = { version = "0.11.2", features = [
"axum", "serde_json", "openapi",
"sqlx", "reqwest", "redis", "validator", "config", "tokio"
] }
Expand All @@ -647,7 +647,7 @@ masterror = { version = "0.11.1", features = [
API (Actix + JSON + deps):

~~~toml
masterror = { version = "0.11.1", features = [
masterror = { version = "0.11.2", features = [
"actix", "serde_json", "openapi",
"sqlx", "reqwest", "redis", "validator", "config", "tokio"
] }
Expand Down Expand Up @@ -718,4 +718,3 @@ MSRV = 1.90 (may raise in minor, never in patch).
Apache-2.0 OR MIT, at your option.

</details>

4 changes: 2 additions & 2 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
~~~toml
[dependencies]
# минимальное ядро
masterror = { version = "0.11.1", default-features = false }
masterror = { version = "0.11.2", default-features = false }
# или с нужными интеграциями
# masterror = { version = "0.11.1", features = [
# masterror = { version = "0.11.2", features = [
# "axum", "actix", "openapi", "serde_json",
# "sqlx", "sqlx-migrate", "reqwest", "redis",
# "validator", "config", "tokio", "multipart",
Expand Down
4 changes: 2 additions & 2 deletions src/response/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl From<AppError> for ErrorResponse {
let code = AppCode::from(kind);
let message = match message {
Some(msg) => msg.into_owned(),
None => String::from("An error occurred")
None => kind.to_string()
};

Self {
Expand All @@ -48,7 +48,7 @@ impl From<&AppError> for ErrorResponse {
let message = err
.message
.clone()
.unwrap_or(Cow::Borrowed("An error occurred"))
.unwrap_or_else(|| Cow::Owned(err.kind.to_string()))
.into_owned();

Self {
Expand Down
14 changes: 12 additions & 2 deletions src/response/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fn from_app_error_uses_default_message_when_none() {
let e: ErrorResponse = (&app).into();
assert_eq!(e.status, 500);
assert!(matches!(e.code, AppCode::Internal));
assert_eq!(e.message, "An error occurred");
assert_eq!(e.message, AppErrorKind::Internal.to_string());
}

#[test]
Expand All @@ -168,7 +168,17 @@ fn from_owned_app_error_defaults_message_when_absent() {

assert_eq!(resp.status, 500);
assert!(matches!(resp.code, AppCode::Internal));
assert_eq!(resp.message, "An error occurred");
assert_eq!(resp.message, AppErrorKind::Internal.to_string());
}

#[test]
fn from_app_error_bare_uses_kind_display_as_message() {
let app = AppError::bare(AppErrorKind::Timeout);
let resp: ErrorResponse = app.into();

assert_eq!(resp.status, 504);
assert!(matches!(resp.code, AppCode::Timeout));
assert_eq!(resp.message, AppErrorKind::Timeout.to_string());
}

// --- Display formatting --------------------------------------------------
Expand Down
Loading