Skip to main content

Crate handle_this

Crate handle_this 

Source
Expand description

handle-this - Ergonomic error handling with try/catch/throw/inspect/finally

§Overview

handle-this provides composable error handling with automatic stack traces. All invocations return Result<T> - no hidden control flow.

§Quick Start

use handle_this::{handle, Result};

fn load_data(path: &str) -> Result<String> {
    handle!{ try { std::fs::read_to_string(path)? } with "reading" }
}

§Patterns

PatternDescription
try { }Execute, wrap error with trace
try { } catch e { }Recover from error
try { } catch Type(e) { }Recover only specific type
try { } throw e { }Transform error
try { } inspect e { }Side effect, then propagate
try { } finally { }Cleanup always runs
try { } with "ctx"Add context
async try { }Async version
try for x in iter { }First success
try any x in iter { }Alias for try for
try all x in iter { }Collect all results
try while cond { }Retry loop

Modules§

result
Result module for try catch blocks.

Macros§

handle
Main error handling macro.

Structs§

Error
Type-erased error wrapper for when you don’t need to preserve the concrete type.
FrameView
View into a single frame of the error trace.
Handled
Error wrapper that captures context and stack traces for any error.
StringError

Enums§

Value
A typed value for structured logging attachments.

Traits§

HandleExt
Extension trait for adding context to Result<T, Handled>.
IntoValue
Trait for converting types into Value.

Type Aliases§

Result
Result type alias.