All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
See the upgrading guide for more detailed information about modifying code to account for new releases.
0.8.3 - 2024-05-24
-
Report
now prints an "Error: " prefix when returned directly frommain
or tests. -
Support heck version 0.5 in addition to 0.4.
0.8.2 - 2024-03-11
-
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.1 - 2024-02-26
- Error types that use constant generics are now supported.
0.8.0 - 2023-12-28
-
snafu(transparent)
allows creating compound error types that act as if they were not present, delegating thierDisplay
andError
implementations to the source error. This is useful when aggregating smaller errors that already completely explain the failure. -
ResultExt::boxed
andResultExt::boxed_local
are 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.
-
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
ChainCompat
iterator 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
location
are 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
Error
trait now marks thedescription
andcause
methods 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.
-
The default
Display
implementation no longer includes the error text of the source error. This is a breaking change. -
The
backtraces
andunstable-backtraces-impl-std
feature flags have been removed. This is a breaking change. TheBacktrace
type is now the standard library'sBacktrace
type when it is available.
0.7.5 - 2023-07-09
- The
CleanedErrorText
iterator 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.
- The documentation for the compatability feature flags now mentions
rust_1_39
and shows the correct default state ofrust_1_61
.
0.7.4 - 2022-12-19
Report
and the#[report]
macro now remove redundant parts from the messages that many errors duplicate from their underlying sources.
0.7.3 - 2022-10-20
- 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
.
0.7.2 - 2022-10-09
-
Report
can be returned frommain
or test functions to provide a user-friendly display of errors. -
A cheat sheet for the most common
#[snafu(...)]
attribute usages has been added to theSnafu
macro's documentation. -
Optional support for using the standard library's
std::backtrace::Backtrace
type via thebacktraces-impl-std
feature flag. -
Optional support for implementing the Provider API using the
std::error::Error::provide
method via theunstable-provider-api
feature flag. -
Optional support for implementing the
core::error::Error
trait instead ofstd::error::Error
via theunstable-core-error
feature flag. -
GenerateImplicitData
has a new methodgenerate_with_source
.
-
ErrorCompat::iter_chain
andChainCompat
are now available in no_std environments. -
ChainCompat
now implementsClone
. -
The
Debug
implementation forLocation
no longer shows some irrelevant internal details.
0.7.1 - 2022-05-02
- The macro
ensure_whatever
provides the functionality of theensure
macro for stringly-typed errors.
-
No longer require the
futures
feature 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
Send
andSync
.
0.7.0 - 2022-01-03
Many breaking changes in this release can be automatically addressed with the snafu-upgrade-assistant.
-
A crate prelude containing common macros and traits can be imported via
use snafu::prelude::*
. -
A ready-to-use error type
Whatever
is 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::Location
can 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::GenerateImplicitData
when the error is created. -
ErrorCompat::iter_chain
provides an iterator over the list of causal errors.
-
Generated context selectors now have the suffix
Snafu
. This is a breaking change. -
ResultExt::with_context
,TryFutureExt::with_context
, andTryStreamExt::with_context
now pass the error into the closure. This is a breaking change. -
The
GenerateBacktrace
trait has been split intoGenerateImplicitData
andAsBacktrace
. This is a breaking change. -
Rust 1.34 is now the minimum supported Rust version. This is a breaking change.
-
String attribute parsing (
#[snafu(foo = "...")]
) is no longer supported. This is a breaking change. -
The deprecated
eager_context
andwith_eager_context
methods have been removed. This is a breaking change.
0.6.10 - 2020-12-03
ensure!
now uses a fully-qualified path to avoid a name clash when the pathcore
is ambiguous.
0.6.9 - 2020-09-21
#[derive(Snafu)]
is now supported on unit structs and structs with fields.ensure!
now supports trailing commas.
- The error text for a misuse of
#[snafu(context)]
was corrected. - More usages of
Option
in the generated code are now fully qualified.
0.6.8 - 2020-05-11
- The code generated by the
Snafu
macro no longer conflicts with a local module calledcore
orsnafu
.
0.6.7 - 2020-05-03
- 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
snafu
crate under a different name using#[snafu(crate_root)]
.
0.6.6 - 2020-04-05
- Context selectors without an underlying cause now have a
build
method in addition to the existingfail
method.build
creates the error but does not wrap it in aResult
.
- This version was a failed publish; please use 0.6.6 instead.
0.6.4 - 2020-04-05
- This version was a failed publish; please use 0.6.6 instead.
0.6.3 - 2020-03-18
- License files are now included with the snafu-derive package.
0.6.2 - 2020-01-17
- Automatically-generated code no longer triggers the
single_use_lifetimes
lint.
0.6.1 - 2020-01-07
- 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(...)
.
- Reduced the possibility for a name collision when implementing
Display
when a formatted value was calledf
.
0.6.0 - 2019-11-07
- Optional support for using the unstable
std::backtrace::Backtrace
type and implementingstd::error::Error::backtrace
via theunstable-backtraces-impl-std
feature flag. - Error variants can now use
Option<Backtrace>
for thebacktrace
field.Backtrace
will 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)]
.
- Rust 1.31 is now the minimum supported Rust version. This is a breaking change.
- The
Backtrace
type 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::Future
has been stabilized, which means the feature flag has been renamed fromunstable-futures
tofutures
. This is a breaking change. - The
backtrace-crate
feature flag has been renamed tobacktraces-impl-backtrace-crate
. Enabling this flag now replacessnafu::Backtrace
withbacktrace::Backtrace
. TheAsRef
implementation has been removed. This is a breaking change. - A new trait for constructing backtraces is used instead of
Default
so theBacktrace
type no longer implementsDefault
or has any inherent methods. This is a breaking change.
0.5.0 - 2019-08-26
- 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.
#[snafu(source(from))
implies#[snafu(source)]
(which implies#[snafu(source(true))]
);#[snafu(source)]
and#[snafu(source(true))]
can be removed in these cases.
- Multiple attributes can be specified inside of a single
#[snafu(...)]
.
#[snafu(backtrace(delegate))]
on source fields is replaced by#[snafu(backtrace)]
. This is a breaking change.
0.4.4 - 2019-08-07
- Ignore
#[doc]
attributes that do not correspond to documentation comments. This allows#[doc(hidden)]
to be used again.
- Implement
Future
andStream
instead ofTryFuture
andTryStream
for the combinators for the standard library's futures. This allows theContext
future combinator to be directly used with.await
and for theContext
stream combinator to be used without calling.into_stream
.
0.4.3 - 2019-07-23
- Add optional conversion of
&snafu::Backtrace
into&backtrace::Backtrace
.
- Support default generic parameters on error types.
0.4.2 - 2019-07-21
- Documentation comment summaries are used as the default
Display
text.
- Quieted warnings from usages of bare trait objects.
- The
From
trait is fully-qualified to avoid name clashes.
- More errors are reported per compilation attempt.
0.4.1 - 2018-05-18
- 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.4.0 - 2018-05-18
-
Context selectors now automatically implement
Debug
,Copy
, andClone
. This is a breaking change. -
Support for futures 0.1 futures and streams is available using the
futures-01
feature flag. -
Experimental support for standard library futures and streams is available using the
unstable-futures
feature flag.
eager_context
andwith_eager_context
have been deprecated.
-
The
Context
type is no longer needed. This is a breaking change. -
SNAFU types no longer implement
Borrow<std::error::Error>
. This is a breaking change.
0.3.1 - 2019-05-10
- Underlying error causes of
Box<dyn std::error::Error + Send + Sync>
are now supported.
Borrow
is 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.
0.3.0 - 2019-05-08
-
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 calledsource
for 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 calledbacktrace
for 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.
- The default
Display
implementation includes the underlying error message.
0.2.3 - 2019-04-24
- User-provided
where
clauses on error types are now copied to SNAFU-createdimpl
blocks. - User-provided inline trait bounds (
<T: SomeTrait>
) are no longer included in SNAFU-generated type names.
0.2.2 - 2019-04-19
- Error enums with variants named
Some
orNone
no longer cause name conflicts in the generated code.
0.2.1 - 2019-04-14
- Deriving
Snafu
on a newtype struct now creates an opaque error type, suitable for conservative public APIs.
0.2.0 - 2019-03-02
snafu::display
andsnafu_display
have been replaced withsnafu(display)
snafu_visibility
has been replaced withsnafu(visibility)
- Backtraces can now be delegated to an underlying error via
#[snafu(backtrace(delegate))]
.
0.1.9 - 2019-03-02
- Error enums with generic lifetimes and types are now supported.
- The trait bounds applied to the
fail
method have been moved from the implementation block to the function itself.
0.1.8 - 2019-02-27
- Visibility is now applied to context selector fields.
0.1.7 - 2019-02-27
#[snafu_visibility]
can be used to configure the visibility of context selectors.
0.1.6 - 2019-02-24
- The
OptionExt
extension trait is now available for convertingOption
s intoResult
s while adding context.
0.1.5 - 2019-02-05
- Errors from the macro are more detailed and point to reasonable sections of code.
0.1.4 - 2019-02-05
- The
ensure
macro is now available.
0.1.3 - 2019-02-04
- Ability to automatically capture backtraces.
- Version requirements for dependencies loosened to allow compiling with more crate versions.
0.1.2 - 2019-02-02
- Support for Rust 1.18
0.1.1 - 2019-02-01
-
Context selectors without an underlying source now have a
fail
method. -
ResultExt
now has theeager_context
andwith_eager_context
methods to eagerly convert a sourceResult
into a finalResult
type, skipping the intermediateResult<_, Context<_>>
type.
0.1.0 - 2019-01-27
Initial version