The night is dark and full of errors, so how should we handle these gracefully and safely in our Rust programs? Let’s introduce two of every Rust programmer’s favourite types: Option and Result.
All tagged errors
The night is dark and full of errors, so how should we handle these gracefully and safely in our Rust programs? Let’s introduce two of every Rust programmer’s favourite types: Option and Result.
Distinguishing between specific error values and types is easy in Go, thanks to the (relatively) new errors.Is and errors.As functions. Let’s talk about what they do, when and how to use them, and how to know which one is appropriate.
Usually what matters about an error is that it’s not nil, but what if we want to know whether it’s some specific error value? For example, in a test? Let’s look at some of the right and wrong ways to do that.
How should we test errors in Go? And how does the need for this testing influence the way we construct, handle, and pass around errors within our Golang programs?