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
| Pattern | Description |
|---|---|
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 catchblocks.
Macros§
- handle
- Main error handling macro.
Structs§
- Error
- Type-erased error wrapper for when you don’t need to preserve the concrete type.
- Frame
View - View into a single frame of the error trace.
- Handled
- Error wrapper that captures context and stack traces for any error.
- String
Error
Enums§
- Value
- A typed value for structured logging attachments.
Traits§
- Handle
Ext - Extension trait for adding context to
Result<T, Handled>. - Into
Value - Trait for converting types into Value.
Type Aliases§
- Result
- Result type alias.