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.
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.