Design an error type the caller can branch on
With Box<dyn Error> all you learn is that it failed. You write the possible failures out as an enum, so that adding one makes the compiler stop every caller. Up to where thiserror ends and anyhow begins.
Projects / Programming languages / Advanced
What you end up with
A class whose rules cannot be broken by any assignment. Errors name the attribute, what was expected and what arrived, and derived values like a total stop drifting.
Sign up for a free membership to read every free project. Already have an account? Please sign in.
Log in to send a report.
With Box<dyn Error> all you learn is that it failed. You write the possible failures out as an enum, so that adding one makes the compiler stop every caller. Up to where thiserror ends and anyhow begins.
You look up a key you know you put in, and get null back. There are four causes, and all of them compile. You measure how entries become unreachable, sort out what a record fixes and what it doesn't, and finish by making the keys immutable.
A goroutine you start with go doesn't end until someone stops it. You count 100 of them lingering after a timeout gives up, find the line where they're stuck, stop them with channels and context, and pin down "no leaks" with a test.