#[derive(CompoundError)]
{
// Attributes available to this derive:
#[compound_error]
}
Expand description
Implement CompoundError functionality for the target type.
If the target is an enum, From is implemented for each variant.
Additionally, variants can be annotated with
#[compound_error( inline_from(X) )]
to specify that an “inlining from X” should be implemented. In addition
to the From impls, by default also std::error::Error and
std::fmt::Display are implemented for the target type. If the target type
is a struct, no From impls, but only std::error::Error and
std::fmt::Display impls are generated.
The generation of the Error and Display impls can by suppressed by
specifying #[compound_error( skip_error )] and
#[compound_error( skip_display )] on the target type.
If the target type is an enum, all variants must take exactly one argument.
By default, this argument must implement std::error::Error. This can be
circumvented by either specifying the skip_error attribute on the target
type or by specifying the no_source attribute on the respective variant.
no_source causes None to be returned by the implementation of
std::error::Error::source() on the target type for the respective enum
variant.
§Attributes
Attributes are specified in the following form:
#[compound_error( attr1, attr2, attr3, ... )]
#[compound_error( attr4, attr5, ... )]
<ELEMENT><ELEMENT> can be the target type or an enum variant. The following
attributes are available:
On the target type:
title = "<title>": Set the title of this error to"<title>". This is relevant for the automaticDisplayimplementation on the target type.description = "<description>": Set the description of this error to"<description>". This is relevant for the automaticDisplayimplementation on the target type.skip_display: Skip the automatic implementation ofstd::fmt::Displayon the target type.skip_error: Skip the automatic implementation ofstd::error::Erroron the target type.transparent: forward the source and Display methods through to all underlying errors without adding an additional message.
On each enum variant:
inline_from(A,B,C,...): Inline the ErrorsA,B,C, … in the target type.no_source: ReturnNonefrom<Self as std::error::Error>::source()for this enum variant. This lifts the requirement thatstd::error::Erroris implemented for the argument of this variant.convert_source(fn): Appliesfnto the error of this variant before returing it from<Self as std::error::Error>::source()transparent: forward the source and Display methods through to the argument of this variant without adding an additional message.