fack
Error handling derive macro for Rust. no_std compatible, doesn't allocate.
use *;
Installation
[]
= "0.1.0"
What's different from thiserror?
- Actually runs in
no_stdenvironments - uses::coreby default, zero heap allocations at runtime - Control inlining with
#[error(inline(...))]- matters for hot paths and code size fack-codegenis a standalone library - use it in your own macros or build scripts- Preserves source spans properly for better IDE integration
If you're writing embedded code or care about allocation-free error handling, this might be useful.
Examples
Basic struct:
use *;
Error chaining:
use *;
Enums with variants:
use *;
Auto-conversion with from:
use *;
// Now you can use ? with these error types
Attributes
Format strings - #[error("message")]
Use {field} for named fields, {_0} for tuple fields. Standard format specifiers work.
;
Source - #[error(source(field))]
Mark which field contains the underlying error. Enables error chain traversal.
Transparent - #[error(transparent(field))]
Forward display and source to an inner error. Useful for wrapper types.
;
From - #[error(from)]
Generate From<T> impl for the error type. Requires exactly one field.
;
Inline - #[error(inline(strategy))]
Control inlining of generated methods. Options: neutral (default), always, never.
// force inline for hot paths
Import - #[error(import(path))]
Override the default ::core import. Use ::std if you need std-specific features.
Documentation
Full docs at docs.rs/fack.
Workspace structure
This repo has four crates:
fack- Main crate, re-exports everythingfack-core- Error trait definitionfack-macro- Procedural macro implementationfack-codegen- Code generation engine
The fack-codegen crate is deliberately not a proc-macro crate. You can depend on it in regular code to build custom error macros or generate errors at build time.
License
GPL-3.0
Copyright (C) 2025 W. Frakchi
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
See LICENSE.md for the full text.