snafu
An ergonomic error handling library
0.9.2
104M downloads/mo
#793 most downloaded on crates.io
shepmaster/snafu
What this package is like to depend on
Last release 1 months ago
21 Jul 2026
Release timing varies
gaps range from 2 weeks to 8 months
Nearly every release is documented
notes for 51 of 51 stable releases
Nothing withdrawn
no release was ever pulled
8 years old
54 releases · first in 2019
4 releases in the last 12 months
see the full history below
Release timeline
54 releases · Jan 2019 to Jul 2026Releases
latest 54-
0.9.221 Jul 2026Release notes
Open source →Fixed
- The
whatevermacro no longer triggers thesemicolon_in_expressions_from_macroslint.
- The
-
0.9.129 May 2026Release notes
Open source →Fixed
- Error types that use
Selfin fields or trait bounds are now supported.
- Error types that use
-
0.9.002 Mar 2026Release notes
Open source →Added
-
WhateverLocalis an alternate toWhateverthat does not implement or requireSendorSync. -
Errors that do not use context selectors (e.g. opaque errors,
#[snafu(context(false))]errors, or#[snafu(transparent)]errors) may now be constructed using a generic value when they are annotated with the#[snafu(source(from(generic)))]attribute. -
When using the
unstable-provider-apifeature flag,Reportwill check if each error provides aLocation. When it does, theLocationwill be appended to the error message.
Fixed
- Opaque errors which use const generics with default values are now supported.
Changed
-
Rust 1.65 is now the minimum supported Rust version. This is a breaking change.
-
Rust 1.81 is now the default supported Rust version. This is a breaking change.
-
WhateverimplementsSendandSync, allowing it to be sent between threads. This requires that wrapped errors also implementSendandSync. This is a breaking change. -
snafu::Locationhas been replaced with a type alias to the standard library'sLocation(specifically a reference to that type:&'static core::panic::Location<'static>). This improves interoperability and access to features. This is a breaking change. -
Opaque errors default to allowing construction from any value that implements
Intofor the wrapped type. The previous behavior can be restored with#[snafu(source(from(exact)))]. This is a breaking change. -
The internal implementation of
#[snafu]attribute parsing has been rewritten. This should largely be unnoticeable, but some error messages and spans have been improved, and memory usage may be slightly reduced.
Removed
-
The deprecated
Error::descriptionandError::causemethods are no longer generated. -
The
rust_1_61,rust_1_65, andunstable-core-errorfeature flags have been removed. -
When using the
unstable-provider-apifeature flag, the source error is no longer provided by default. This impacts regular and opaque errors, as well asWhateverandWhateverLocal. -
When using the
unstable-provider-apifeature flag, provided values may no longer be chained or have chaining priority assigned.
-
-
0.8.903 Sep 2025Release notes
Open source →Fixed
- Allow the
unstable-provider-apifeature to be used in a no_std environment, both with and without theallocfeature flag enabled.
- Allow the
-
0.8.828 Aug 2025Release notes
Open source →Fixed
-
Gate
TryFuture::whatever_context,TryFuture::with_whatever_context,TryStream::whatever_context, andTryStream::with_whatever_contextbehind theallocfeature flag. This allows SNAFU's future and stream combinators to be used in a no_std environment. -
Only implement
GenerateImplicitDataandAsBacktraceforArcwrappers when the target platform has access to atomics andArc.
-
-
0.8.720 Aug 2025Release notes
Open source →Added
GenerateImplicitDataandAsBacktraceare now implemented forBox<T>,Rc<T>, andArc<T>whenTimplements the same trait. This allows you to use types likeArc<Backtrace>as a backtrace field.
-
0.8.628 May 2025Release notes
Open source →Added
-
A new
allocfeature flag has been added as a subset of the existingstdfeature flag. This allows SNAFU to be used in environments that have access to an allocator but not the standard library. -
Context selectors may now be explicitly named. This allows flexibility in edge cases, but also is understood by rust-analyzer to help with renaming context selectors.
Fixed
- Added
#[allow(dead_code)]to the context selector'sfailmethod. This works around an issue with thedead_codelint in rare usages involving declarative macros and explicit visibility qualifiers.
Changed
-
Add top-level documentation on reporting errors using
#[snafu::report]. -
Show the
cfgoptions that control features on docs.rs.
-
-
0.8.523 Sep 2024Release notes
Open source →Added
- Implement the
core::error::Errortrait instead ofstd::error::Errorwhen therust_1_81feature flag is enabled. This supersedes theunstable-core-errorfeature flag.
- Implement the
-
0.8.408 Jul 2024Release notes
Open source →Fixed
- Use the fully-qualified path to
Locationin thelocation!()macro.
- Use the fully-qualified path to
-
0.8.324 May 2024Release notes
Open source →Changed
-
Reportnow prints an "Error: " prefix when returned directly frommainor tests. -
Support heck version 0.5 in addition to 0.4.
-
-
0.8.211 Mar 2024Release notes
Open source →Fixed
-
Adding a custom Whatever variant to a generic error enum is now supported.
-
The
#[report]macro works better on functions that require more complicated type inference for their return types.
-
-
0.8.126 Feb 2024 -
0.8.030 Dec 2023Release notes
Open source →Added
-
snafu(transparent)allows creating compound error types that act as if they were not present, delegating thierDisplayandErrorimplementations to the source error. This is useful when aggregating smaller errors that already completely explain the failure. -
ResultExt::boxedandResultExt::boxed_localare available to convert an error value into an owned trait object. This is useful when an error type is a generic controlled by the caller.
Changed
-
Rust 1.56 is now the minimum supported Rust version. This is a breaking change.
-
Rust 1.65 is now the default supported Rust version. This is a breaking change.
-
The item type of the
ChainCompatiterator is now&'a (dyn Error + 'b)to allow downcasting the error trait object to a concrete type. This is a breaking change. -
Error fields marked
locationare no longer automatically implicitly created. This is a breaking change. -
Adding
#[snafu]attributes to the field of a tuple struct are now errors. This is a breaking change. -
The SNAFU copy of the
Errortrait now marks thedescriptionandcausemethods as deprecated, following the standard library's example. This trait is only active when using SNAFU in a no_std environment and no functional difference is intended.
Removed
-
The default
Displayimplementation no longer includes the error text of the source error. This is a breaking change. -
The
backtracesandunstable-backtraces-impl-stdfeature flags have been removed. This is a breaking change. TheBacktracetype is now the standard library'sBacktracetype when it is available.
-
-
0.7.509 Jul 2023Release notes
Open source →Added
- The
CleanedErrorTextiterator can be used to remove redundant parts from the messages that many errors duplicate from their underlying sources. This is the same behavior asReport, but can be used in contexts other than console output, such as when reporting an error in structured output like HTML or JSON.
Fixed
- The documentation for the compatability feature flags now mentions
rust_1_39and shows the correct default state ofrust_1_61.
- The
-
0.7.419 Dec 2022Release notes
Open source →Changed
Reportand the#[report]macro now remove redundant parts from the messages that many errors duplicate from their underlying sources.
-
0.7.320 Oct 2022Release notes
Open source →Fixed
- The macro no longer generates invalid code when implicitly-generated
types (such as backtraces) were used in conjunction with
#[snafu(source(from))]and the type before transformation does not implementstd::error::Error.
- The macro no longer generates invalid code when implicitly-generated
types (such as backtraces) were used in conjunction with
-
0.7.210 Oct 2022Release notes
Open source →Added
-
Reportcan be returned frommainor test functions to provide a user-friendly display of errors. -
A cheat sheet for the most common
#[snafu(...)]attribute usages has been added to theSnafumacro's documentation. -
Optional support for using the standard library's
std::backtrace::Backtracetype via thebacktraces-impl-stdfeature flag. -
Optional support for implementing the Provider API using the
std::error::Error::providemethod via theunstable-provider-apifeature flag. -
Optional support for implementing the
core::error::Errortrait instead ofstd::error::Errorvia theunstable-core-errorfeature flag. -
GenerateImplicitDatahas a new methodgenerate_with_source.
Changed
-
ErrorCompat::iter_chainandChainCompatare now available in no_std environments. -
ChainCompatnow implementsClone. -
The
Debugimplementation forLocationno longer shows some irrelevant internal details.
-
-
0.7.103 May 2022Release notes
Open source →Added
- The macro
ensure_whateverprovides the functionality of theensuremacro for stringly-typed errors.
Changed
-
No longer require the
futuresfeature flag to support the shim implementations of standard library errors that have existed since Rust 1.34. -
Documentation improved to demonstrate that custom Whatever errors can optionally be made
SendandSync.
- The macro
-
0.7.004 Jan 2022Release notes
Open source →Many breaking changes in this release can be automatically addressed with the snafu-upgrade-assistant.
Added
-
A crate prelude containing common macros and traits can be imported via
use snafu::prelude::*. -
A ready-to-use error type
Whateveris available to quickly start reporting errors with little hassle. -
"Stringly typed" error cases can be added to existing error types, allowing you to construct errors without defining them first.
-
Formatting shorthand syntax for error type data fields is now supported:
#[snafu(display("Hello {name}"))]. -
#[snafu(module)]can be specified on an error type. This will create a module for the error type and all associated context selectors will be placed in that module. -
snafu::Locationcan be added to an error type to provide lightweight tracking of the source location where the error was created. -
#[snafu(implicit)]can be specified on context selector data fields to automatically generate it viasnafu::GenerateImplicitDatawhen the error is created. -
ErrorCompat::iter_chainprovides an iterator over the list of causal errors.
Changed
-
Generated context selectors now have the suffix
Snafu. This is a breaking change. -
ResultExt::with_context,TryFutureExt::with_context, andTryStreamExt::with_contextnow pass the error into the closure. This is a breaking change. -
The
GenerateBacktracetrait has been split intoGenerateImplicitDataandAsBacktrace. This is a breaking change. -
Rust 1.34 is now the minimum supported Rust version. This is a breaking change.
Removed
-
String attribute parsing (
#[snafu(foo = "...")]) is no longer supported. This is a breaking change. -
The deprecated
eager_contextandwith_eager_contextmethods have been removed. This is a breaking change.
-
-
0.7.0-beta.215 Nov 2021 pre-releaseNothing published for this version
-
0.7.0-beta.107 Oct 2021 pre-releaseNothing published for this version
-
0.7.0-beta.005 Jul 2021 pre-releaseNothing published for this version
-
0.6.1003 Dec 2020Release notes
Open source →Fixed
ensure!now uses a fully-qualified path to avoid a name clash when the pathcoreis ambiguous.
-
0.6.922 Sep 2020Release notes
Open source →Added
#[derive(Snafu)]is now supported on unit structs and structs with fields.ensure!now supports trailing commas.
Fixed
- The error text for a misuse of
#[snafu(context)]was corrected. - More usages of
Optionin the generated code are now fully qualified.
-
0.6.812 May 2020Release notes
Open source →Fixed
- The code generated by the
Snafumacro no longer conflicts with a local module calledcoreorsnafu.
- The code generated by the
-
0.6.703 May 2020Release notes
Open source →Added
- Demonstration error types are now present in the guide.
- The user's guide is now an optional feature flag. To preserve compatibility, it is enabled by default, but most users can disable it.
- It is now possible to import the
snafucrate under a different name using#[snafu(crate_root)].
-
0.6.605 Apr 2020Release notes
Open source →Added
- Context selectors without an underlying cause now have a
buildmethod in addition to the existingfailmethod.buildcreates the error but does not wrap it in aResult.
- Context selectors without an underlying cause now have a
-
0.6.505 Apr 2020 -
0.6.405 Apr 2020 -
0.6.319 Mar 2020 -
0.6.217 Jan 2020Release notes
Open source →Added
- Automatically-generated code no longer triggers the
single_use_lifetimeslint.
- Automatically-generated code no longer triggers the
-
0.6.108 Jan 2020Release notes
Open source →Added
- It is now possible to create errors that have no context using
#[snafu(context(false))]. This allows using the question mark operator without calling.context(...).
Fixed
- Reduced the possibility for a name collision when implementing
Displaywhen a formatted value was calledf.
- It is now possible to create errors that have no context using
-
0.6.007 Nov 2019Release notes
Open source →Added
- Optional support for using the unstable
std::backtrace::Backtracetype and implementingstd::error::Error::backtracevia theunstable-backtraces-impl-stdfeature flag. - Error variants can now use
Option<Backtrace>for thebacktracefield.Backtracewill always have the backtrace collected, whileOption<Backtrace>requires that an environment variable be set. - Basic support for no-std environments.
- The
ensure!macro now allows creating opaque errors. - Context selectors have basic documentation generated. This allows
using
#[deny(missing_docs)].
Changed
- Rust 1.31 is now the minimum supported Rust version. This is a breaking change.
- The
Backtracetype is now always available, but does nothing by default. It is recommended that the end application enables backtrace functionality. This is a breaking change. - Support for
std::future::Futurehas been stabilized, which means the feature flag has been renamed fromunstable-futurestofutures. This is a breaking change. - The
backtrace-cratefeature flag has been renamed tobacktraces-impl-backtrace-crate. Enabling this flag now replacessnafu::Backtracewithbacktrace::Backtrace. TheAsRefimplementation has been removed. This is a breaking change. - A new trait for constructing backtraces is used instead of
Defaultso theBacktracetype no longer implementsDefaultor has any inherent methods. This is a breaking change.
- Optional support for using the unstable
-
0.5.026 Aug 2019Release notes
Open source →Added
- Compiler errors are generated when SNAFU attributes are used in incorrect locations. This is a breaking change.
- Compiler errors are generated when SNAFU attributes are duplicated. This is a breaking change.
Changed
#[snafu(source(from))implies#[snafu(source)](which implies#[snafu(source(true))]);#[snafu(source)]and#[snafu(source(true))]can be removed in these cases.
Fixed
- Multiple attributes can be specified inside of a single
#[snafu(...)].
Removed
#[snafu(backtrace(delegate))]on source fields is replaced by#[snafu(backtrace)]. This is a breaking change.
-
0.4.407 Aug 2019Release notes
Open source →Fixed
- Ignore
#[doc]attributes that do not correspond to documentation comments. This allows#[doc(hidden)]to be used again.
Changed
- Implement
FutureandStreaminstead ofTryFutureandTryStreamfor the combinators for the standard library's futures. This allows theContextfuture combinator to be directly used with.awaitand for theContextstream combinator to be used without calling.into_stream.
- Ignore
-
0.4.324 Jul 2019Release notes
Open source →Added
- Add optional conversion of
&snafu::Backtraceinto&backtrace::Backtrace.
Fixed
- Support default generic parameters on error types.
- Add optional conversion of
-
0.4.221 Jul 2019Release notes
Open source →Added
- Documentation comment summaries are used as the default
Displaytext.
Fixed
- Quieted warnings from usages of bare trait objects.
- The
Fromtrait is fully-qualified to avoid name clashes.
Changed
- More errors are reported per compilation attempt.
- Documentation comment summaries are used as the default
-
0.4.119 May 2019Release notes
Open source →Fixed
- A feature flag name was rejected by crates.io and needed to be updated; this release has no substantial changes beyond 0.4.0.
-
0.3.111 May 2019Release notes
Open source →Fixed
- Underlying error causes of
Box<dyn std::error::Error + Send + Sync>are now supported.
Deprecated
Borrowis no longer required to be implemented for underlying error causes. In the next release containing breaking changes, the automatic implementation ofBorrow<dyn std::error::Error>for SNAFU types will be removed.
- Underlying error causes of
-
0.3.009 May 2019Release notes
Open source →Added
-
Borrow<std::error::Error>is now automatically implemented for SNAFU types. This is a breaking change as it may conflict with an existing user implementation of the same trait. It is expected that the number of affected users is very small. -
#[snafu(source)]can be used to identify the field that corresponds to the underlying error if it is not calledsource. It can also be used to disable automatically using a field calledsourcefor the underlying error. -
#[snafu(backtrace)]can be used to identify the field that corresponds to the backtrace if it is not calledbacktrace. It can also be used to disable automatically using a field calledbacktracefor the backtrace. -
#[snafu(source(from(...type..., ...expression...)))]can be used to perform transformations on the underlying error before it is stored. This allows boxing of large errors to avoid bloated return types or recursive errors. -
The user guide has a basic comparison to Failure and migration paths for common Failure patterns.
Changed
- The default
Displayimplementation includes the underlying error message.
-
-
0.2.324 Apr 2019Release notes
Open source →Fixed
- User-provided
whereclauses on error types are now copied to SNAFU-createdimplblocks. - User-provided inline trait bounds (
<T: SomeTrait>) are no longer included in SNAFU-generated type names.
- User-provided
-
0.2.219 Apr 2019Release notes
Open source →Fixed
- Error enums with variants named
SomeorNoneno longer cause name conflicts in the generated code.
- Error enums with variants named
-
0.2.115 Apr 2019Release notes
Open source →Added
- Deriving
Snafuon a newtype struct now creates an opaque error type, suitable for conservative public APIs.
- Deriving
-
0.2.026 Mar 2019Release notes
Open source →Removed
snafu::displayandsnafu_displayhave been replaced withsnafu(display)snafu_visibilityhas been replaced withsnafu(visibility)
Added
- Backtraces can now be delegated to an underlying error via
#[snafu(backtrace(delegate))].
-
0.1.902 Mar 2019Release notes
Open source →Added
- Error enums with generic lifetimes and types are now supported.
Changed
- The trait bounds applied to the
failmethod have been moved from the implementation block to the function itself.
-
0.1.828 Feb 2019 -
0.1.728 Feb 2019Release notes
Open source →Added
#[snafu_visibility]can be used to configure the visibility of context selectors.
-
0.1.624 Feb 2019Release notes
Open source →Added
- The
OptionExtextension trait is now available for convertingOptions intoResults while adding context.
- The
-
0.1.510 Feb 2019Release notes
Open source →Changed
- Errors from the macro are more detailed and point to reasonable sections of code.
-
0.1.406 Feb 2019 -
0.1.305 Feb 2019Release notes
Open source →Added
- Ability to automatically capture backtraces.
Changed
- Version requirements for dependencies loosened to allow compiling with more crate versions.
-
0.1.202 Feb 2019 -
0.1.101 Feb 2019Release notes
Open source →Added
-
Context selectors without an underlying source now have a
failmethod. -
ResultExtnow has theeager_contextandwith_eager_contextmethods to eagerly convert a sourceResultinto a finalResulttype, skipping the intermediateResult<_, Context<_>>type.
-
-
0.1.028 Jan 2019