News for hackers. Stuff that matters.
Re:Why Use Structured Errors in Rust Applications? by Arnavion on Sunday June 01, 2025 @12:04PM (#44151846)
If you don't `impl From<UnderlyingError> for MyError` then you can force the code to do `.map_err(|err| MyError::new(err, context))?` instead of just `?`.

This doesn't work when the error is already MyError so you want to make sure that `context` contains everything you might want to know about the call stack.

Re:Why Use Structured Errors in Rust Applications? by fn-mote on Sunday June 01, 2025 @01:40PM (#44152525)
Four optional fields one for each potential context really strikes me as a code-smell / anti-pattern.

Your application gets a new context and you add another field? There must be a better way to do this.

Re:Why Use Structured Errors in Rust Applications? by Arnavion on Sunday June 01, 2025 @01:55PM (#44152618)
The better way is to do what I wrote in the first paragraph; ie each layer gets its own error type with a bespoke context type. The second paragraph is about the case where you want to use a single error type.