#thiserror

2024-08-05

I was struggeling to report the source cause of an error in a codebase!

The crate and crate seemed to be the right set of tools for this.
Although it hasn't been easy to figure out!
( but I didn't even cry 😏)

Once you master both, error reporting in becomes fun, standardized, colorful and painless!

2024-07-11

Interesting read about #snafu vs #thiserror: medium.com/@greptime_team/erro

The stack_trace_debug macro proposed reminds me strongly of the error_chain construct in chapter 8 of @algo_luca's Zero To Production In Rust. zero2prod.com/index.html

#RustLang #ErrorHandling

Jan :rust: :ferris:janriemer@floss.social
2022-11-28

@greysemanticist It works, because thiserror generates a From impl for rusqlite::Error for your AuthError (due to the #[from] attribute).

And ? will use that From impl to return AuthError.

See also the std #Rust docs on how ? works:

"When applied to values of the Result<T, E> type, it propagates errors. If the value is Err(e), then it will return Err(From::from(e)) from the enclosing function or closure."

doc.rust-lang.org/reference/ex

#thiserror and ? can look like magic, but it's just #RustLang

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst