Expand description
§errcraft
Beautiful, structured, and colorful error handling for Rust.
§Overview
errcraft provides a composable error type that supports:
- Rich context with key-value pairs and text annotations
- Nested error chaining with beautiful tree rendering
- Colorful CLI output with emoji support
- Smart backtrace capture and filtering
- JSON and Markdown serialization
- Integration with popular error handling crates
§Quick Start
use errcraft::ErrFrame;
fn read_config(path: &str) -> Result<String, ErrFrame> {
std::fs::read_to_string(path).map_err(|e| {
ErrFrame::new("Failed to read config file")
.context("path", path.to_string())
.with_source(e)
})
}§Features
std(default): Standard library support withstd::error::Errorbacktrace(default): Capture and display backtracescolors-owo(default): Colorful output using owo-colorsserde: JSON serialization supportmarkdown: Markdown rendering utilitiesemoji: Enable emoji glyphs in output- Integration features:
anyhow,eyre,thiserror,tracing,axum
Macros§
- bail
- Creates an error and returns it immediately.
- craft
- Creates a new
ErrFramewith a formatted message. - ensure
- Ensures a condition is true, otherwise returns an error.
Structs§
- Context
Layer - A single layer of context attached to an error.
- Display
Options std - Options for controlling error display.
- ErrFrame
- The main error type for errcraft.
Enums§
- Backtrace
Mode std - Backtrace display mode.
- Color
Mode std - Color mode for error display.
- Context
Value - A context value that can be attached to an error.
Type Aliases§
- ErrResult
- A
Resulttype alias that usesErrFrameas the error type.