Skip to main content

Crate redacted_error

Crate redacted_error 

Source
Expand description

Stable public error messages with debug-only diagnostic detail.

redacted-error gives applications a small facade for errors that cross crate, process, API, or protocol boundaries:

The default build uses obfstr internally for static public messages. Build with default-features = false to use plain literals instead. The public macros stay the same either way.

§Security

This crate is a leakage-reduction tool, not a confidentiality boundary.

  • The obfuscate feature only raises the bar against trivial strings-style inspection of compiled binaries. It is not a defense against a debugger, dynamic instrumentation, symbol tables, or any motivated reverse engineer. Do not treat obfuscated literals as secret.

  • Diagnostic-detail stripping is gated on cfg(debug_assertions). That cfg is on in the dev profile and off in the standard release profile, but Cargo lets users opt back in with [profile.release] debug-assertions = true. Under that override every detail! / display / [detail] call leaks runtime detail in release builds. Avoid that combination if redaction matters.

  • The detail! macro skips evaluating its format arguments in release. The [detail] and display free functions still evaluate (and drop) their argument, because the cfg branch lives inside the function body. Prefer the macro when the argument has nontrivial cost or side effects.

Macros§

detail
Formats runtime diagnostic detail in debug builds and strips it in release builds.
impl_redacted_debug
Implements release Debug by delegating to Display.
message
Returns a public-facing message for a string literal.
message_string
Returns an owned public-facing message.

Structs§

Message
Public-facing message text.

Traits§

ErrorCode
Machine-readable code for errors that cross process or API boundaries.
PublicError
Stable public message for errors that cross process or API boundaries.

Functions§

detail
Captures runtime diagnostic detail in debug builds and strips it in release builds.
display
Formats runtime diagnostic detail in debug builds and strips it in release builds.