5 unstable releases

0.3.0-rc.2 Nov 10, 2024
0.3.0-rc.1 Oct 20, 2024
0.2.3 Sep 4, 2024
0.2.1 Aug 29, 2024
0.0.0 Jul 8, 2024

#1581 in Rust patterns

Download history 105/week @ 2024-08-26 253/week @ 2024-09-02 30/week @ 2024-09-16 7/week @ 2024-09-23 8/week @ 2024-09-30 26/week @ 2024-10-14 143/week @ 2024-10-21 67/week @ 2024-10-28 63/week @ 2024-11-04 48/week @ 2024-11-11 7/week @ 2024-11-18 5/week @ 2024-12-02

120 downloads per month
Used in liboptic_edid

MIT license

26KB
88 lines

pisserror

A golden replacement for thiserror.

Usage

You'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:

use pisserror::Error;
use std::error::Error; // we don't mess with your prelude :D

#[derive(Debug, Error)]
pub enum DatabaseError {
    #[error("encountered a disk error. see: {_0}")]
    DiskError(#[from] std::io::Error),
    #[error("key `{_0}` has no matching data records")]
    KeyNotFound(String),
    #[error("attempted to store a malformed header. expected: `{expected:?}`. got: `{got:?}`")]
    MalformedHeader {
        expected: String,
        got: String,
    },
    #[error("other error: {_0}")]
    Other(String),
}

Also, 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.

Alternatively, you can add it to Cargo.toml by adding default-features = false:

[dependencies]
pisserror = { version = (your version), default-features = false }

Feature Requests and Problems

If there's something wrong or missing, please create a GitHub issue! Make sure to thoroughly describe your intentions.

Contributions

Contributions are welcome! Please create a PR and explain the changes you made.

There are a few ground rules, though:

  • All contributions are bound by the license.
  • Commits must be in Conventional Commits format. Feel free to interpret the rules a bit, though!
  • Document and test your work.

Making a Release

There are only a few steps to releasing this crate.

  1. Generate the README.md file using cargo-rdme.
  2. Change the version numbers in /Cargo.toml and /macros/Cargo.toml.
    • Under the dependencies.pisserror_macros section, you must also change the version number to match the new release.
  3. Run cargo publish!

Dependencies

~230–670KB
~16K SLoC