Error types for a Rust library, and a different answer for a binary
A library's error type is public API that callers match on. A binary mostly needs a clear message with context. thiserror and anyhow fit those two jobs.
Topic · 10 stories
10 stories tagged error-handling on AI Tamer, newest first.
A library's error type is public API that callers match on. A binary mostly needs a clear message with context. thiserror and anyhow fit those two jobs.
Errexit skips failures in conditions, && and || lists, negated commands and early pipeline stages. Learn the rules from the Bash manual and POSIX, and how pipefail closes the pipeline gap.
Rust can catch an unwinding plugin panic, but the host must still decide whether captured state remains valid. UnwindSafe is a warning at that boundary, not automatic rollback.
Checked, saturating and wrapping arithmetic encode different overflow policies. Pick one for the meaning of a counter, image dimension or protocol sequence.
A poisoned Rust mutex signals that a thread panicked while holding the lock. Recovery starts with checking the shared state’s invariants.
A Rust library can reserve room for new error variants. Downstream callers need a deliberate fallback when matching them.
RFC 9457 gives HTTP API errors a standard JSON shape. Learn which fields clients can rely on and how to define useful problem types.
How to handle a model response that arrives in pieces. It covers server-sent events, partial JSON, user cancellation, and what is safe to store.
An outer error can explain what failed at its layer while keeping the lower-level cause available for diagnosis.
How to choose an error type for a small Rust tool. Plain enums need no dependency, thiserror removes the boilerplate, and anyhow adds context for applications.