« Back to Index

Rust: anyhow vs thiserror

View original Gist on GitHub

Tags: #rust #errorhandling

Rust anyhow vs thiserror.md

anyhow helps create error values out of arbitrary strings.

Helpful to wrap error messages that don’t need distinct types, which is often the case in applications that just end up logging the error and don’t need to distinguish between lots of types.

thiserror helps make proper errors out of custom types (e.g. an enum with lots of different variants).

Helpful if you want to give each possible error its own type, which is often the case in libraries.