# rtb-error
> Part of the [phpboyscout Rust toolkit](https://rust.phpboyscout.uk):
> small, framework-free crates extracted from
> [rust-tool-base](https://gitlab.com/phpboyscout/rust-tool-base).
Error types and the diagnostic report pipeline: the canonical `Error`
enum, the `Result<T, E = Error>` alias, exit-code attachment
(`WithExitCode` / `exit_code_of`), and the process-edge `miette` hook
pipeline (report handler, panic hook, mutable footer). Errors are
values: propagated with `?`, rendered once at `main()`.
```rust
#[tokio::main]
async fn main() -> miette::Result<()> {
rtb_error::hook::install_report_handler();
rtb_error::hook::install_panic_hook();
// ...
Ok(())
}
```
Install the hooks as the *first* statement in `main`. `miette`'s renderer
slot is filled by whichever comes first, your install call or the first
`Report` constructed anywhere in the process, and losing that race is
silent.
- **Docs:** <https://error.rust.phpboyscout.uk>
- [Tutorial: give your CLI a diagnostic error path](https://error.rust.phpboyscout.uk/tutorials/01-give-your-cli-a-diagnostic-error-path/)
- [How-to guides](https://error.rust.phpboyscout.uk/how-to/): install the pipeline, define an error type, set an exit code, add a footer
- [Reference](https://error.rust.phpboyscout.uk/reference/): every variant, code, default and failure mode
- [What rtb-error does not do](https://error.rust.phpboyscout.uk/explanation/03-what-this-does-not-do/)
- **API reference:** <https://docs.rs/rtb-error>
- **Crate:** <https://crates.io/crates/rtb-error>
## Development
`just ci` runs the full local gate (fmt, clippy, nextest, doc, deny).
Tests include a cucumber BDD suite (`tests/bdd.rs`) and trybuild
compile-fail fixtures (`tests/trybuild.rs`). Run them with
`cargo nextest run`, because the global-hook tests need nextest's
process-per-test isolation. Releases are cut by colophon from
Conventional Commits, so do not tag manually.
## License
MIT