Skip to content

Instantly share code, notes, and snippets.

View byterip's full-sized avatar
🎶

byterip byterip

🎶
  • under the carpet
View GitHub Profile
@quad
quad / 0-modular-errors-with-rusts-thiserror.md
Last active October 31, 2025 19:58
Modular Errors with Rust's thiserror

I've been writing Rust full-time with a small team for over a year now. Throughout, I've lamented the lack of clear best practices around defining error types. One day, I'd love to write up my journey and enumerate the various strategies I've both seen and tried. Today is not that day.

Today, I want to reply to a blog post that almost perfectly summarised my current practice.

Go read it; I'll wait!


@luca992
luca992 / gist:ad305d1e39fb9cfeae91bf997607654f
Last active August 2, 2025 08:08
Rust Snafu Errors Example
use snafu::Snafu;
/// Error type for all API traits
/// Note: Do not put implementation specific errors here (so no errors from reqwest, serde, etc.)
/// These should be generic errors that can be used by any API implementation.
/// The implementation specific errors should be defined locally for each API implementation then
/// converted to this error type before being returned.
///
/// Hint: use [From] to convert implementation specific errors to this error type. You can define
/// an error snafu enum inside the same file as an api implementation and also implement the