pisserror/
lib.rs

1/*!# pisserror
2
3A golden replacement for `thiserror`.
4
5## Usage
6
7You'll likely find `pisserror` to be pretty familiar. As with `thiserror`, it derives `Error` for any enum you give to it. Here's a sample of its current usage:
8
9```
10use pisserror::Error;
11use std::error::Error; // we don't mess with your prelude :D
12
13#[derive(Debug, Error)]
14pub enum DatabaseError {
15    #[error("encountered a disk error. see: {_0}")]
16    DiskError(#[from] std::io::Error),
17    #[error("key `{_0}` has no matching data records")]
18    KeyNotFound(String),
19    #[error("attempted to store a malformed header. expected: `{expected:?}`. got: `{got:?}`")]
20    MalformedHeader {
21        expected: String,
22        got: String,
23    },
24    #[error("other error: {_0}")]
25    Other(String),
26}
27```
28
29Also, you may wish to note that `pisserror` works with `#![no_std]`/embedded projects! Just ask `cargo add` to not use default features, like `cargo add pisserror --no-default-features`.
30
31Alternatively, you can add it to `Cargo.toml` by adding `default-features = false`:
32
33```toml
34[dependencies]
35pisserror = { version = (your version), default-features = false }
36```
37
38## Feature Requests and Problems
39
40If there's something wrong or missing, please create a GitHub issue! Make sure to thoroughly describe your intentions.
41
42## Contributions
43
44Contributions are welcome! Please create a PR and explain the changes you made.
45
46There are a few ground rules, though:
47
48- All contributions are bound by the [license](./LICENSE).
49- Commits must be in [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format. Feel free to interpret the rules a bit, though!
50- Document and test your work.
51
52### Making a Release
53
54There are only a few steps to releasing this crate.
55
561. Generate the `README.md` file using `cargo-rdme`.
571. Change the version numbers in `/Cargo.toml` and `/macros/Cargo.toml`.
58    - Under the `dependencies.pisserror_macros` section, you must also change the version number to match the new release.
591. Run `cargo publish`!
60*/
61#![cfg_attr(not(feature = "std"), no_std)]
62
63#[cfg(doctest)]
64pub mod _doctests;
65
66pub use pisserror_macros::Error;