#[derive(Error)]
{
// Attributes available to this derive:
#[error]
#[display]
#[no_constructors]
#[no_debug]
#[from]
}
Expand description
Derive macro for automatically implementing error traits.
Supports the following attributes:
#[error]- Mark the field containing theOhnoCore. At most one field may be marked. With no marker the macro looks for a single field whose type is namedOhnoCore, so a core reached through a type alias or a renamed import has to be marked#[display("...")]- Custom display message with field interpolation. Positional arguments are implicitly scoped toself, so fields are referenced by their bare name (path.display(), notself.path.display())#[no_constructors]- Disable automatic constructor generation. The generatednew()andcaused_by()arepub(crate)even when the error type ispub, so an error type that needs a public constructor declares one by hand. Rejected under#[ohno::error], which adds theOhnoCorefield a hand-written constructor would have to initialize#[no_debug]- Disable automatic Debug trait implementation#[from(Type1, Type2, ...)]- Generate From implementations for specified types
By default, automatically implements std::fmt::Debug unless #[no_debug] is specified, so an
existing manual #[derive(Debug, Error)] collides: drop the manual Debug derive, or add
#[no_debug] to keep it.
See the main ohno crate documentation for detailed usage examples.