Justerror
Extension to `thiserror` that helps reduce the amount of handwriting
Install / Use
/learn @shakacode/JusterrorREADME
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: stringfmt: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
qqbot-channel
345.4kQQ 频道管理技能。查询频道列表、子频道、成员、发帖、公告、日程等操作。使用 qqbot_channel_api 工具代理 QQ 开放平台 HTTP 接口,自动处理 Token 鉴权。当用户需要查看频道、管理子频道、查询成员、发布帖子/公告/日程时使用。
docs-writer
100.0k`docs-writer` skill instructions As an expert technical writer and editor for the Gemini CLI project, you produce accurate, clear, and consistent documentation. When asked to write, edit, or revie
model-usage
345.4kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
ddd
Guía de Principios DDD para el Proyecto > 📚 Documento Complementario : Este documento define los principios y reglas de DDD. Para ver templates de código, ejemplos detallados y guías paso
