facet-error
facet-error
A thiserror replacement powered by facet reflection. This crate is a plugin for #[derive(Facet)] that generates Display and Error trait implementations from doc comments.
Usage
use Facet;
This generates:
impl Display for MyErrorusing doc comments as format stringsimpl Error for MyErrorwith propersource()implementation- Field interpolation works automatically for struct variants (e.g.,
{expected},{found}) - Tuple variants support positional interpolation (e.g.,
{0})
Features
- Doc-driven Display: Doc comments become your error messages
- Field interpolation: Reference struct fields by name in messages
- Zero boilerplate: No manual Display or Error implementations
- Integration with facet: Works seamlessly with the facet reflection system
Future Work
#[facet(error::source)]- mark fields as error sources#[facet(error::from)]- generateFromimplementations- Support for error wrapping and transparent delegation
Sponsors
Thanks to all individual sponsors:
...along with corporate sponsors:
...without whom this work could not exist.
Special thanks
The facet logo was drawn by Misiasart.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.