Comment by mxey
3 hours ago
> You literally cannot dereference an Option without acknowledging the None case. Whole categories of pager-duty incidents disappear.
This is at the very least misleading, given that you can use unwrap.
Regarding error handling: will a parser error in the config return an error that includes the name of the file that’s failed to parse? That’s the kind of useful context that I add to errors in Go.
The difference is, unwrap will stick out like a sore thumb, and it’s opt-in. You explicitly tell "this may panic".
As for error handling, this kind of enrichment is usually left to the caller (that is, the end application), with error libraries like anyhow where you can add arbitrary string contexts to an error. You would end up writing `Config::load(path).with_context(|| format!("Failed to load configuration file {path}"))?`.