SkillAgentSearch skills...

Justerror

Extension to `thiserror` that helps reduce the amount of handwriting

Install / Use

/learn @shakacode/Justerror
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

justerror

<img alt="github" src="https://img.shields.io/badge/github-shakacode/justerror-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20"> <img alt="crates.io" src="https://img.shields.io/crates/v/justerror.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20"> <img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-justerror-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs" height="20">

<!-- cargo-sync-readme start -->

This macro piggybacks on thiserror crate and is supposed to reduce the amount of handwriting when you want errors in your app to be described via explicit types (rather than anyhow).

ShakaCode

If you are looking for help with the development and optimization of your project, ShakaCode can help you to take the reliability and performance of your app to the next level.

If you are a developer interested in working on Rust / ReScript / TypeScript / Ruby on Rails projects, we're hiring!

Installation

Add to Cargo.toml:

justerror = "0.1"

Add to main.rs:

#[macro_use]
extern crate justerror;

Usage

This macro takes a subject struct or enum and applies thiserror attributes with predefined #[error] messages.

Generally, you can attach #[Error] macro to an error type and be done with it.

#[Error]
enum EnumError {
    Foo,
    Bar {
        a: &'static str,
        b: usize
    },
}

eprintln!("{}", EnumError::Bar { a: "Hey!", b: 42 });

// EnumError::Bar
// === ↴
// a: Hey!
// b: 42

Macro accepts two optional arguments:

  • desc: string
  • fmt: display | debug | "<custom format>"

Both can be applied at the root level.

#[Error(desc = "My emum error description", fmt = debug)]
enum EnumError {
    Foo(usize),
}

And at the variant level.

#[Error(desc = "My emum error description", fmt = debug)]
enum EnumError {
    #[error(desc = "Foo error description", fmt = display)]
    Foo(usize),
}

fmt can also be applied to individual fields.

#[Error(desc = "My emum error description", fmt = debug)]
enum EnumError {
    #[error(desc = "Foo error description", fmt = display)]
    Foo(#[fmt(">5")] usize),
}

See tests for more examples.

<!-- cargo-sync-readme end -->

License

MIT.

Related Skills

View on GitHub
GitHub Stars13
CategoryContent
Updated19d ago
Forks0

Languages

Rust

Security Score

75/100

Audited on Mar 14, 2026

No findings