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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [0.21.1] - 2025-10-09

### Fixed
- Packed rarely used `AppError` context (source and backtrace slots) inside the
boxed inner payload so the `AppResult` alias no longer triggers Clippy's
`result_large_err` lint under `-D warnings`.

## [0.21.0] - 2025-10-08

### Added
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.21.0"
version = "0.21.1"
rust-version = "1.90"
edition = "2024"
license = "MIT OR Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ The build script keeps the full feature snippet below in sync with

~~~toml
[dependencies]
masterror = { version = "0.21.0", default-features = false }
masterror = { version = "0.21.1", default-features = false }
# or with features:
# masterror = { version = "0.21.0", features = [
# masterror = { version = "0.21.1", features = [
# "axum", "actix", "openapi", "serde_json",
# "tracing", "metrics", "backtrace", "sqlx",
# "sqlx-migrate", "reqwest", "redis", "validator",
Expand Down
4 changes: 2 additions & 2 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ MSRV зафиксирован, а родные деривы позволяют

~~~toml
[dependencies]
masterror = { version = "0.21.0", default-features = false }
masterror = { version = "0.21.1", default-features = false }
# или с нужными фичами:
# masterror = { version = "0.21.0", features = [
# masterror = { version = "0.21.1", features = [
# "axum", "actix", "openapi", "serde_json",
# "tracing", "metrics", "backtrace", "sqlx",
# "sqlx-migrate", "reqwest", "redis", "validator",
Expand Down
40 changes: 20 additions & 20 deletions src/app_error/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,25 @@ pub enum MessageEditPolicy {
#[doc(hidden)]
pub struct ErrorInner {
/// Stable machine-readable error code.
pub code: AppCode,
pub code: AppCode,
/// Semantic error category.
pub kind: AppErrorKind,
pub kind: AppErrorKind,
/// Optional, public-friendly message.
pub message: Option<Cow<'static, str>>,
pub message: Option<Cow<'static, str>>,
/// Structured metadata for telemetry.
pub metadata: Metadata,
pub metadata: Metadata,
/// Policy describing whether the message can be redacted.
pub edit_policy: MessageEditPolicy,
pub edit_policy: MessageEditPolicy,
/// Optional retry advice rendered as `Retry-After`.
pub retry: Option<RetryAdvice>,
pub retry: Option<RetryAdvice>,
/// Optional authentication challenge for `WWW-Authenticate`.
pub www_authenticate: Option<String>,
telemetry_dirty: AtomicBool
pub www_authenticate: Option<String>,
pub source: Option<Arc<dyn StdError + Send + Sync + 'static>>,
#[cfg(feature = "backtrace")]
pub backtrace: Option<Backtrace>,
#[cfg(feature = "backtrace")]
pub captured_backtrace: OnceLock<Option<Backtrace>>,
telemetry_dirty: AtomicBool
}

#[cfg(feature = "backtrace")]
Expand Down Expand Up @@ -156,12 +161,7 @@ mod test_backtrace_override {
/// Rich application error preserving domain code, taxonomy and metadata.
#[derive(Debug)]
pub struct Error {
inner: Box<ErrorInner>,
source: Option<Arc<dyn StdError + Send + Sync + 'static>>,
#[cfg(feature = "backtrace")]
backtrace: Option<Backtrace>,
#[cfg(feature = "backtrace")]
captured_backtrace: OnceLock<Option<Backtrace>>
inner: Box<ErrorInner>
}

impl Deref for Error {
Expand Down Expand Up @@ -228,13 +228,13 @@ impl Error {
edit_policy: MessageEditPolicy::Preserve,
retry: None,
www_authenticate: None,
source: None,
#[cfg(feature = "backtrace")]
backtrace: None,
#[cfg(feature = "backtrace")]
captured_backtrace: OnceLock::new(),
telemetry_dirty: AtomicBool::new(true)
}),
source: None,
#[cfg(feature = "backtrace")]
backtrace: None,
#[cfg(feature = "backtrace")]
captured_backtrace: OnceLock::new()
})
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/app_error/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,3 +548,12 @@ fn result_alias_is_generic() {
assert!(matches!(default_result, Ok(value) if value == 1));
assert!(matches!(custom_result, Ok(value) if value == 2));
}

#[test]
fn app_error_fits_result_budget() {
let size = std::mem::size_of::<AppError>();
assert!(
size <= 128,
"AppError grew to {size} bytes; keep the Err variant lean"
);
}
Loading