Comment by tuetuopay
2 hours ago
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}"))?`.
No comments yet
Contribute on Hacker News ↗