Crate errcraft

Crate errcraft 

Source
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 with std::error::Error
  • backtrace (default): Capture and display backtraces
  • colors-owo (default): Colorful output using owo-colors
  • serde: JSON serialization support
  • markdown: Markdown rendering utilities
  • emoji: 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 ErrFrame with a formatted message.
ensure
Ensures a condition is true, otherwise returns an error.

Structs§

ContextLayer
A single layer of context attached to an error.
DisplayOptionsstd
Options for controlling error display.
ErrFrame
The main error type for errcraft.

Enums§

BacktraceModestd
Backtrace display mode.
ColorModestd
Color mode for error display.
ContextValue
A context value that can be attached to an error.

Type Aliases§

ErrResult
A Result type alias that uses ErrFrame as the error type.